/* Fri Dec 30 19:43:15 JST 2005 */ #include #include #include #include #include enum original_t { LD = 26, MB, MP, NC, ND, NG, NT, NW, PS, QU, CW, TS }; using namespace std; string alphabets[38] = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "ld", "mb", "mp", "nc", "nd", "ng", "nt", "nw", "ps", "qu", "cw", "ts" }; int Kan_order(string word, vector &order) { for (int i = 0; i < word.length(); i++) { if (i == word.length() - 1) { order.push_back((int)word[i] - 'a'); continue; } switch (word[i]) { case 'l': if (word[i+1] == 'd') { order.push_back(LD); i++; } else { order.push_back((int)word[i] - 'a'); } break; case 'm': if (word[i+1] == 'b') { order.push_back(MB); i++; } else if (word[i+1] == 'p') { order.push_back(MP); i++; } else { order.push_back((int)word[i] - 'a'); } break; case 'n': if (word[i+1] == 'c') { order.push_back(NC); i++; } else if (word[i+1] == 'd') { order.push_back(ND); i++; } else if (word[i+1] == 'g') { order.push_back(NG); i++; } else if (word[i+1] == 't') { order.push_back(NT); i++; } else if (word[i+1] == 'w') { order.push_back(NW); i++; } else { order.push_back((int)word[i] - 'a'); } break; case 'p': if (word[i+1] == 's') { order.push_back(PS); i++; } else { order.push_back((int)word[i] - 'a'); } break; case 'q': if (word[i+1] == 'u') { order.push_back(QU); i++; } else { order.push_back((int)word[i] - 'a'); } break; case 'c': if (word[i+1] == 'w') { order.push_back(CW); i++; } else { order.push_back((int)word[i] - 'a'); } break; case 't': if (word[i+1] == 's') { order.push_back(TS); i++; } else { order.push_back((int)word[i] - 'a'); } break; default: order.push_back((int)word[i] - 'a'); } } } void count_sequence(const vector &order, map, int> &counts) { for (int i = 0; i < order.size() - 1; i++) { if (order[i] >= 38) { cout << "!"; } counts[make_pair(order[i], order[i+1])]++; } } int main() { int n; while (cin >> n && n > 0) { string s; map, int> counts; getline(cin, s); for (int i = 0; i < n; i++) { getline(cin, s); istringstream iss(s); string word; while (iss >> word) { vector order; Kan_order(word, order); count_sequence(order, counts); } } for (int i = 0; i < 38; i++) { int max_j = 0, max_count = 0; for (int j = 0; j < 38; j++) { if (max_count < counts[make_pair(i, j)]) { max_j = j; max_count = counts[make_pair(i, j)]; } } cout << alphabets[i] << " " << alphabets[max_j] << " " << counts[make_pair(i, max_j)] << endl; } } return 0; }