extern crate core;

use std::fmt;
use std::cmp::{Ordering, min, max};
use std::fmt::{Display, Error, Formatter, Binary};
use std::f32::MAX;
use std::ops::{Add, Sub, Mul, Div, Neg, Index, IndexMut};
use std::collections::{BTreeMap, VecDeque, BinaryHeap, BTreeSet};

fn show<T: Display>(vec: &Vec<T>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        print!("[{}", vec[0]);
        for i in 1 .. vec.len() {
            print!(", {}", vec[i]);
        }
        println!("]");
    }
}
fn show2<T: Display>(vec: &Vec<Vec<T>>) {
    if vec.is_empty() {
        println!("[]");
    }else {
        for l in vec {
            show(l);
        }
    }
}
macro_rules! read_line{
    () => {{
        let mut line = String::new();
        std::io::stdin().read_line(&mut line).ok();
        line
    }};
    (delimiter: ' ') => {
        read_line!().split_whitespace().map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (delimiter: $p:expr) => {
        read_line!().split($p).map(|x|x.to_string()).collect::<Vec<_>>()
    };
    (' ') => {
        read_line!(delimiter: ' ')
    };
    ($delimiter:expr) => {
        read_line!(delimiter: $delimiter)
    };
    (' '; $ty:ty) => {
        read_line!().split_whitespace().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
    ($delimiter:expr; $ty:ty) => {
        read_line!($delimiter).into_iter().map(|x|x.parse::<$ty>().ok().unwrap()).collect::<Vec<$ty>>()
    };
}
macro_rules! read_value{
    () => {
        read_line!().trim().parse().ok().unwrap()
    }
}
macro_rules! let_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
macro_rules! let_mut_all {
    ($($n:ident:$t:ty),*) => {
        let line = read_line!(delimiter: ' ');
        let mut iter = line.iter();
        $(let mut $n:$t = iter.next().unwrap().parse().ok().unwrap();)*
    };
}
fn to_code(name: &String) -> String {
    let name: Vec<_> = name.chars().collect();
    let mut rest: Vec<char> = vec![*name.first().unwrap()];
    for i in 1 .. name.len() {
        match name[i - 1] {
            'a' | 'i' | 'u' | 'e' | 'o' => rest.push(name[i]),
            _ => {}
        }
    }
    rest.iter().collect()
}
fn longest_common_prefix_length(a: &String, b: &String) -> usize {
    let mut zip = a.chars().zip(b.chars());
    zip.position(|(a, b)| a != b).unwrap_or(min(a.len(), b.len()))
}
fn main() {
    loop {
        let_all!(n: usize);
        if n == 0 {
            return
        }
        let mut words = Vec::<String>::with_capacity(n);
        for _ in 0 .. n {
            words.push(to_code(&read_value!()));
        }
        words.sort();
        let mut max_length = 0;
        for i in 1 .. n {
            if words[i - 1] == words[i] {
                max_length = -1;
                break
            }else {
                let len = longest_common_prefix_length(&words[i - 1], &words[i]) + 1;
                if max_length < len as i32 {
                    max_length = len as i32;
                }
            }
        }
        println!("{}", max_length);
    }
}


Measured memory_bytes: 5052