#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");
    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++){
            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')
                        ||(vs[j][k]=='t'&&vs[j][k+1]=='s')
                        ||(vs[j][k]=='q'&&vs[j][k+1]=='u')
                        ||(vs[j][k]=='p'&&vs[j][k+1]=='s')
                        ||(vs[j][k]=='n'&&vs[j][k+1]=='w')
                        ||(vs[j][k]=='n'&&vs[j][k+1]=='t')
                        ||(vs[j][k]=='n'&&vs[j][k+1]=='g')
                        ||(vs[j][k]=='n'&&vs[j][k+1]=='d')
                        ||(vs[j][k]=='n'&&vs[j][k+1]=='c')
                        ||(vs[j][k]=='m'&&vs[j][k+1]=='p')
                        ||(vs[j][k]=='m'&&vs[j][k+1]=='b')
                        ||(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);
        }
        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;
        }
        cout<<revDict[i]<<" "<<revDict[cd]<<" "<<score<<endl;
    }

    return 0;
}

Measured memory_bytes: 0