#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define faster() ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
bool checktn(string a){
string s=a;
reverse(a.begin(), a.end());
if(a==s) return true;
return false;
}
struct cmp{
bool operator () (string a, string b){
if(a.size()==b.size()) return a>b;
else return a.size()>b.size();
}
};
int main(){
faster();
map<string, int, cmp> mp;
string s;
while(cin>>s){
if(checktn(s)&&s.size()>2) mp[s]++;
}
for(auto it: mp){
cout<<it.first<<" "<<it.second<<endl;
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4gCnVzaW5nIG5hbWVzcGFjZSBzdGQ7IAojZGVmaW5lIGxsIGxvbmcgbG9uZwojZGVmaW5lIGZhc3RlcigpIGlvczo6c3luY193aXRoX3N0ZGlvKGZhbHNlKTsgY2luLnRpZShudWxscHRyKTsgY291dC50aWUobnVsbHB0cik7CmJvb2wgY2hlY2t0bihzdHJpbmcgYSl7CiAgICBzdHJpbmcgcz1hOwogICAgcmV2ZXJzZShhLmJlZ2luKCksIGEuZW5kKCkpOwogICAgaWYoYT09cykgcmV0dXJuIHRydWU7CiAgICByZXR1cm4gZmFsc2U7Cn0Kc3RydWN0IGNtcHsKICAgIGJvb2wgb3BlcmF0b3IgKCkgKHN0cmluZyBhLCBzdHJpbmcgYil7CiAgICAgICAgaWYoYS5zaXplKCk9PWIuc2l6ZSgpKSByZXR1cm4gYT5iOwogICAgICAgIGVsc2UgcmV0dXJuIGEuc2l6ZSgpPmIuc2l6ZSgpOwogICAgfQp9OwppbnQgbWFpbigpewogICAgZmFzdGVyKCk7CiAgICBtYXA8c3RyaW5nLCBpbnQsIGNtcD4gbXA7CiAgICBzdHJpbmcgczsKICAgIHdoaWxlKGNpbj4+cyl7CiAgICAgICAgaWYoY2hlY2t0bihzKSYmcy5zaXplKCk+MikgbXBbc10rKzsKICAgIH0KICAgIGZvcihhdXRvIGl0OiBtcCl7CiAgICAgICAgY291dDw8aXQuZmlyc3Q8PCIgIjw8aXQuc2Vjb25kPDxlbmRsOwogICAgfSAKfQ==