s = input()
a = dict()
for i in range(len(s)):
try:
a[s[i]] += 1
except:
a[s[i]] = 1
for k, v in a.items():
print(k, v)
s = input()
a = dict()
for i in range(len(s)):
try:
a[s[i]] += 1
except:
a[s[i]] = 1
for k, v in a.items():
print(k, v)