while True:
    try:
        obj=input()
        tdata=input()
        for i in range(len(obj)):
            count=tdata.count(obj[i])
            print(f'{obj[i]} {count}')
    except EOFError:
        break