include
include
include
using namespace std;
int main() {
string s, x;
while (getline(cin,s) ) {
if (s == "#") {
break;
}
getline(cin,x);
for (int i = 0; i < s.size(); ++i) {
int sum = 0;
for (int j = 0; j < x.size(); ++j) {
if (s[i] == x[j]) {
sum++;
}
}
cout << s[i] << " " << sum << endl;
}
}
return 0;
}