//zadanie: połowa
#include<bits/stdc++.h>
using namespace std;
int licz(string &napis, char litera)
{
int cnt = 0;
for(auto znak: napis) cnt += znak == litera;
return cnt;
}
int main(){
int t;
cin>>t;
string napis;
cin.ignore();//usuwamy enter z bufora, aby działała funkcja getline
while(t--)
{
getline(cin, napis);
for(char lit = 'a'; lit <= 'z'; lit++)
{
int policz = licz(napis, lit);
if(policz > 0)
cout<<lit<<' '<<policz<<endl;
}
}
return 0;
}
Ly96YWRhbmllOiBwb8WCb3dhCiNpbmNsdWRlPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbGljeihzdHJpbmcgJm5hcGlzLCBjaGFyIGxpdGVyYSkKewoJaW50IGNudCA9IDA7Cglmb3IoYXV0byB6bmFrOiBuYXBpcykgY250ICs9IHpuYWsgPT0gbGl0ZXJhOwoJcmV0dXJuIGNudDsKfQoKaW50IG1haW4oKXsKCWludCB0OwoJY2luPj50OwoJc3RyaW5nIG5hcGlzOwoJY2luLmlnbm9yZSgpOy8vdXN1d2FteSBlbnRlciB6IGJ1Zm9yYSwgYWJ5IGR6aWHFgmHFgmEgZnVua2NqYSBnZXRsaW5lCgl3aGlsZSh0LS0pCgl7CgkJZ2V0bGluZShjaW4sIG5hcGlzKTsKCQlmb3IoY2hhciBsaXQgPSAnYSc7IGxpdCA8PSAneic7IGxpdCsrKQoJCXsKCQkJaW50IHBvbGljeiA9IGxpY3oobmFwaXMsIGxpdCk7CgkJCWlmKHBvbGljeiA+IDApCgkJCQljb3V0PDxsaXQ8PCcgJzw8cG9saWN6PDxlbmRsOwoJCX0KCX0KCXJldHVybiAwOwp9IA==