### constant

K2CHS = ["ld", "mb", "mp", "nc", "nd", "ng", "nt", "nw", "ps", "qu", "cw", "ts"]
K1CHS = ('a'..'z').to_a
KCHS = K1CHS + K2CHS

### subroutines

def split_word(word)
  chs = []
  i = 0
  wlen = word.length
  while i < wlen
    ch2 = word[i, 2]
    if $kcodes[ch2]
      chs << ch2
      i += 2
      next
    end
    chs << word[i]
    i += 1
  end
  chs
end

### main

$kcodes = {}
KCHS.each_with_index{|c, i| $kcodes[c] = i}
#p $kcodes; exit

pairs = KCHS.map{KCHS.map{0}}

n = gets.to_i

n.times do
  for word in gets.strip.split
    pcc = nil
    for ch in split_word(word)
      cc = $kcodes[ch]
      if ! pcc.nil?
        pairs[pcc][cc] += 1
      end
      pcc = cc
    end
  end
end

for pcc in (0...KCHS.length)
  max_pn = 0
  max_cc = 0

  for cc in (0...KCHS.length)
    pn = pairs[pcc][cc]
    if max_pn < pn
      max_pn = pn
      max_cc = cc
    end
  end

  puts [KCHS[pcc], KCHS[max_cc], max_pn].join(' ')
end