#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

vector<string> split(string v,char del){
	vector<string> strs;
	int head=0;
	for(int j = 0; j < v.size(); j++){
		if(v[j]==del){
			strs.push_back(v.substr(head,j-head));
			head=j+1;
		}
		else if(j==v.size()-1){
			strs.push_back(v.substr(head,j-head+1));
		}
	}
	return strs;
}


int main(){
    map<string,int> dict;
    int idx=0;
    vector<string> revDict;
    for(char i = 'a'; i <= 'z'; i++){
        string s;s+=i;
        revDict.push_back(s);
        dict[s]=idx++;
    }
    dict["ld"]=idx++;revDict.push_back("ld");
    dict["mb"]=idx++;revDict.push_back("mb");
    dict["mp"]=idx++;revDict.push_back("mp");
    dict["nc"]=idx++;revDict.push_back("nc");
    dict["nd"]=idx++;revDict.push_back("nd");
    dict["ng"]=idx++;revDict.push_back("ng");
    dict["nt"]=idx++;revDict.push_back("nt");
    dict["nw"]=idx++;revDict.push_back("nw");
    dict["ps"]=idx++;revDict.push_back("ps");
    dict["qu"]=idx++;revDict.push_back("qu");
    dict["cw"]=idx++;revDict.push_back("cw");
    dict["ts"]=idx++;revDict.push_back("ts");
    vector<pair<string,int> > cand;
    // candÌvfªo»µ½çA»ê¼êÉ¶½zñÌvfðvX
    for(map<string,int>::iterator it=dict.begin();it!=dict.end();it++){
        for(map<string,int>::iterator iit=dict.begin();iit!=dict.end();iit++){
            if(it->first.size()==1&&iit->first.size()==1){
                string s=it->first+iit->first;
                // 1¶¸ÂÅ2¶ªìêÄÍ¢¯È¢
                if(dict.find(s)!=dict.end())
                    continue;
            }
            cand.push_back(make_pair((it->first)+(iit->first),it->first.size()));
        }
    }
    int freq[101][101];
    memset(freq,0,sizeof(freq));
    int n;
    cin>>n;
    string str;
    getline(cin,str);
    int cnt=0;
    for(int i = 0; i < n; i++){
        getline(cin,str);
        vector<string> vs=split(str,' ');
        vector<vector<string> > vvs;
        for(int j = 0; j < vs.size(); j++){
            if(j==3){
   //             cout<<endl;
            }
            vector<string> vv;
            // ªð·é
            for(int k = 0; k < vs[j].size(); k++){
                if(vs[j].size()-1!=k){
                    string s;
                    // Ì¨Åêí¯
                    if(vs[j][k]=='c'&&vs[j][k+1]=='w'){
                        s+=vs[j][k];
                        s+=vs[j][k+1];
                    }
                    else if(vs[j][k]=='t'&&vs[j][k+1]=='s'){
                        s+=vs[j][k];
                        s+=vs[j][k+1];
                    }
                    else if(vs[j][k]=='q'&&vs[j][k+1]=='u'){
                        s+=vs[j][k];
                        s+=vs[j][k+1];
                    }
                    else if(vs[j][k]=='p'&&vs[j][k+1]=='s'){
                        s+=vs[j][k];
                        s+=vs[j][k+1];
                    }
                    else if(vs[j][k]=='n'&&vs[j][k+1]=='w'){
                        s+=vs[j][k];
                        s+=vs[j][k+1];
                    }
                    else if(vs[j][k]=='n'&&vs[j][k+1]=='t'){
                        s+=vs[j][k];
                        s+=vs[j][k+1];
                    }
                    else if(vs[j][k]=='n'&&vs[j][k+1]=='g'){
                        s+=vs[j][k];
                        s+=vs[j][k+1];
                    }
                    else if(vs[j][k]=='n'&&vs[j][k+1]=='d'){
                        s+=vs[j][k];
                        s+=vs[j][k+1];
                    }
                    else if(vs[j][k]=='n'&&vs[j][k+1]=='c'){
                        s+=vs[j][k];
                        s+=vs[j][k+1];
                    }
                    else if(vs[j][k]=='m'&&vs[j][k+1]=='p'){
                        s+=vs[j][k];
                        s+=vs[j][k+1];
                    }
                    else if(vs[j][k]=='m'&&vs[j][k+1]=='b'){
                        s+=vs[j][k];
                        s+=vs[j][k+1];
                    }
                    else if(vs[j][k]=='l'&&vs[j][k+1]=='d'){
                        s+=vs[j][k];
                        s+=vs[j][k+1];
                    }
                    else{
                        s+=vs[j][k];
                        k--;
                    }
                    k++;
                    vv.push_back(s);
                }
                else{
                    string s;
                    s+=vs[j][k];
                    vv.push_back(s);
                }
            }
            vvs.push_back(vv);
        }

        // vvsÉÍªðµ½stringªüÁÄ¢éÌÅA»êððÍ·é¾¯
        for(int j = 0; j < vvs.size(); j++){
            for(int k = 0; k < vvs[j].size()-1; k++){
                int prv=dict[vvs[j][k]];
                int nxt=dict[vvs[j][k+1]];
                freq[prv][nxt]++;
            }
        }
    }
    for(int i = 0; i < dict.size(); i++){
        int cd;
        int score=-1;
        for(int j = dict.size()-1; j >= 0; j--){
            if(freq[i][j]>score){
                score=freq[i][j];
                cd=j;
            }
            else if(freq[i][j]==score)
                cd=j;
        }
        // ÅXRAÌàÌð\¦
        cout<<revDict[i]<<" "<<revDict[cd]<<" "<<score<<endl;
    }

    return 0;
}

Measured memory_bytes: 1012