#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

/**
 * 统计字符--浙江大学
 * @return
 */
int main() {

    string str1;
    string str2;
    while (getline(cin, str1)) {        //读入测试
        if (str1 == "#") {
            break;
        }
        getline(cin, str2);
        //记录每个字符出现的次数
        int count[128] = {0};
        /*
         * 先遍历str2,统计str2中每个字符出现的次数
         * 以字符的ASCII码作为count[]数组的索引
         */
        for (int i = 0; i < str2.size(); ++i) {
            count[str2[i]]++;
        }
        /*
         * 遍历str1,获取需要统计的字符
         * 通过count[]数组查看该字符出现的次数
         */
        for (int j = 0; j < str1.size(); ++j) {
            cout << str1[j] << " " << count[str1[j]] << endl;
        }
    }

    return 0;
}