#include<cstdio>
#include<string>
#include<cstring>
using namespace std ;

int main() {
    char arr[10];
   fgets(arr, 10, stdin);
        string buf = arr ;
        arr[buf.size() - 1] = '\0';
        int count[10]={0} ;
        count[buf.size() - 1] = '\0';
        char var[80];
        fgets(var, 80, stdin);
        string str = var;
        var[str.size() - 1] = '\0';
        for (int i = 0; i < buf.size() - 1; ++i) {
            for (int j = 0; j < str.size(); ++j) {
                if (buf[i] == str[j]) {
                    ++count[i];
                }
            }
            printf("%c %d\n", buf[i], count[i]);
        }


    }