def tongji(s2, s1):
    d = {}
    for i in s2:
        print(i,end='')
        c=0
        for j in s1:
            if i == j:
                 c+=1
        print(" %d"%c)


while True:
    try:
        s1 = input()
        s2 = input()
        tongji(s1, s2)

    except:

        break