loop do
  n = gets.to_i
  break if n == 0
  s = []
  longest = 0
  n.times do
    str = gets.chomp
    replaced = str[0]
    str.chars.each_cons(2) do |ch1, ch2|
      replaced += ch2 if ch1.match(/[aiueo]/)
    end
    s << replaced
    longest = replaced.size if replaced.size > longest
  end

  k = 0
  succeed = false
  ns = []
  while k <= longest
    k += 1
    ns = s.map { |str| str[0...k] }
    if ns.uniq.size == ns.size
      succeed = true
      puts k
      break
    end
  end

  puts -1 unless succeed
end