#include <bits/stdc++.h>
using namespace std;

int main(){
int t;
cin>>t;
while(t--){
string s;
cin>>s;
map<char,int> mp;
for(int i=0; i<s.size(); i++){
           mp[s[i]]++;
}
string ans;
for(auto x:mp){
   ans+=x.first;
ans+=':';
ans+= to_string(x.second);
ans+=" ";
}

cout<<ans<<endl;
}
return 0;
}