#include<iostream> #include<string> #include<cstdio> using namespace std; int main() { string s1, s2; while (getline(cin, s1)) { for (int k = 0; k < s1.size(); k++) { if (s1[k] == '#') { return 0; } } getline(cin, s2); for (int k = 0; k < s2.size(); k++) { if (s2[k] == '#') { return 0; } } for (int i = 0; i < s1.size(); i++) { int num = 0; for (int j = 0; j < s2.size(); j++) { if (s1[i] == s2[j]) { num++; } } cout << s1[i] << " " << num << endl; } } return 0; }