def generate_ac(name)
  ac = name[0]

  name.split("").each_cons(2){|n| ac += n[1] if n[0].match(/[aiueo]/)}
  
  ac
end

def calc_minimam_k(ac_list)
  return -1 if ac_list.uniq.size == 1
  
  max_ac_length = ac_list.max_by{|ac| ac.length }.length
  
  max_ac_length.times do |n|
    return n + 1 if ac_list.uniq.size == ac_list.map{ |ac| ac[0..n] }.uniq.size
  end
end

loop do
  n = gets.to_i
  break if n == 0
  ac_list = []
  
  n.times do
    ac_list << generate_ac(gets.chomp)
  end
  
  puts calc_minimam_k(ac_list)
end