#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;
    } 
}