/**/
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <string>
#include <stack>
#include <queue>
typedef long long LL;
using namespace std;
string s1, s2;
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
while(getline(cin , s1)){
if(s1[0] == '#') break;
getline(cin ,s2);
map<char, int>mp;
int len2 = s2.size(), len1 = s1.size();
for (int i = 0; i < len2; i++){
mp[s2[i]]++;
}
for (int i = 0; i < len1; i++){
printf("%c %d\n", s1[i], mp[s1[i]]);
}
}
return 0;
}
/**/