//土尔逊Torson 编写于2023/4/18
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
int number[128];
int main() {
string str1, str2;
while (getline(cin, str1)) {
if (str1 == "#") {
break;
}
getline(cin, str2);
memset(number, 0, sizeof(number)); //初始化数组
for (int i = 0; i < str2.size(); ++i) {
number[str2[i]]++;
}
for (int i = 0; i < str1.size(); ++i) {
printf("%c %d\n", str1[i], number[str1[i]]);
}
}
system("pause");
return EXIT_SUCCESS;
}
// 64 位输出请用 printf("%lld")