Problem:
Airport Codes
空港コード
JAG王国では国内の空港にそれぞれ空港コードを割り当てて識別をしている．
空港コードは，小文字の英語アルファベットで表記した空港の名前をもとに以下の規則で割り当てられる:
名前の最初の文字と，母音 (a,i,u,e,o) の直後の文字を順に取り出す．
取り出した文字列が
k
文字未満ならそれを空港コードとし，
k
文字以上なら，その取り出した文字列の先頭
k
文字を空港コードとして使う．
例えば
k
= 3 のとき，haneda には hnd ， oookayama には ooo ， tsu には t というコードが割り当てられる．
しかしこのコードの割り当て方では，違う名前の空港でも同じコードが割り当てられることがあり，混乱を招いてしまう．
空港の名前の一覧が与えられるので，すべての空港のコードが異なるようにできるか判定して，可能な場合はすべての空港コードが異なるようにできる最小の
k
を求め，不可能な場合はその旨を伝えるプログラムを作成せよ．
Input
入力は100個以下のデータセットからなる．
それぞれのデータセットは次の形式で与えられる．
n
s
1
...
s
n
1行目に空港の数
n
(2 ≤
n
≤ 50) が整数で与えられ，続く
n
行にはそれぞれ空港の名前
s
i
が文字列で与えられる．
空港の名前は'
a
'から'
z
'の小文字の英語アルファベットのみで構成され，いずれも文字数は1以上50以下である． 
また，与えられる空港の名前はすべて異なる．すなわち，1 ≤
i
<
j
≤
n
のとき
s
i
≠
s
j
を満たす．
入力の終わりは1つのゼロだけからなる行で示される．
Output
それぞれのデータセットについて，すべての空港に相異なる空港コードを割り当てられるときは，そのような最小の
k
を1行に出力せよ．
不可能な場合は，-1を1行に出力せよ．
Sample Input
3
haneda
oookayama
tsu
2
azusa
azishirabe
2
snuke
snake
4
haneda
honda
hanamaki
hawaii
0
Output for Sample Input
1
4
-1
3

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using a2 = array<ll, 2>;
using a3 = array<ll, 3>;

template <typename A> void chmin(A &l, const A &r) {
    if(r < l)
        l = r;
}
template <typename A> void chmax(A &l, const A &r) {
    if(l < r)
        l = r;
}

ll mod = 998244353;

ll n;
vector<string> s;
void input() {
    cin >> n;
    s.resize(n);
    for(auto &x : s)
        cin >> x;
}

void solve() {

    set<char> boin;

    boin.insert('a');
    boin.insert('i');
    boin.insert('u');
    boin.insert('e');
    boin.insert('o');

    for(int i = 0; i < 100; i++) {
        set<string> sh;
        for(auto &x : s) {
            string add;
            for(int j = 0; j < x.size(); j++) {
                add.push_back(x[j]);
                for(; j < x.size(); j++) {
                    if(boin.count(x[j]))
                        break;
                }
            }

            sh.insert(add.size() >= i ? add.substr(0, i + 1) : add);
        }
        if(sh.size() == n) {
            cout << i + 1 << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    while(1) {
        input();
        if(n == 0)
            break;
        solve();
    }

    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3364
final_rank: 13

code_snippet: #include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <ranges>
#include <regex>
#include <set>
#include <span>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
// #include <atcoder/dsu>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(a) a.begin(), a.end()
using namespace std;

template <class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <class T1, class T2>
std::ostream &operator<<(std::ostream &out, const pair<T1, T2> &A) {
	cout << "{" << A.first << "," << A.second << "}";
	return out;
}

template <class T1, class T2>
std::ostream &operator<<(std::ostream &out, const map<T1, T2> &M) {
	for (const auto &A : M) {
		cout << "{" << A.first << "," << A.second << "}";
	}
	return out;
}

template <class T1>
std::ostream &operator<<(std::ostream &out, const set<T1> &M) {
	cout << "{";
	for (const auto &A : M) {
		cout << A << ", ";
	}
	cout << "}" << endl;
	return out;
}

template <class T1>
std::ostream &operator<<(std::ostream &out, const multiset<T1> &M) {
	cout << "{";
	for (const auto &A : M) {
		cout << A << ", ";
	}
	cout << "}" << endl;
	return out;
}

template <class T>
std::ostream &operator<<(std::ostream &out, const vector<T> &A) {
	for (const T &a : A) {
		cout << a << " ";
	}
	return out;
}

void print() { cout << endl; }

template <typename Head, typename... Tail>
void print(Head H, Tail... T) {
	cout << H << " ";
	print(T...);
}

template <class T>
std::istream &operator>>(std::istream &in, vector<T> &A) {
	for (T &a : A) {
		std::cin >> a;
	}
	return in;
}

using ll = long long;
// using mint = modint1000000007;
// using PII = pair<int, int>;
// using PLL = pair<ll, ll>;
// using Graph = vector<vector<int>>;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr ll LINF = numeric_limits<ll>::max() / 2;

// ランレングス圧縮
// イテレータを受け取る
// verify: https://atcoder.jp/contests/abc380/submissions/60002447
template <typename T, typename Iterator>
vector<pair<T, int>> RLE(Iterator begin, Iterator end) {
	vector<pair<T, int>> res;
	for (auto itr = begin; itr != end; ++itr) {
		if (res.empty() || res.back().first != *itr) {
			res.emplace_back(*itr, 1);
		} else {
			res.back().second++;
		}
	}
	return res;
}

// 座標圧縮
// unordered_mapが使えない場合はmapに変更しよう
// https://atcoder.jp/contests/abc213/submissions/60002695
template <typename T>
unordered_map<T, int> compress(vector<T> &X) {
	auto tmp = X;
	ranges::sort(tmp);
	tmp.erase(unique(tmp.begin(), tmp.end()), tmp.end());
	unordered_map<T, int> res;
	for (int i = 0; i < (int)tmp.size(); i++) {
		res[tmp[i]] = i;
	}
	return res;
}
bool solve() {
	// ここからスタート
	int n;
	cin >> n;
	if (n == 0) return false;
	auto getcode = [](string s, int k) {
		string boin = "aiueo";
		set<char> st{boin.begin(), boin.end()};
		string ret;
		ret.push_back(s.front());
		for (int i = 1; i < int(s.size()); i++) {
			if (st.contains(s[i - 1])) {
				ret.push_back(s[i]);
			}
			if (int(ret.size()) >= k) break;
		}
		return ret;
	};
	vector<string> s(n);
	rep(i, n) cin >> s[i];
	for (int k = 1; k <= 50; k++) {
		set<string> st;
		for (auto &si : s) {
			st.insert(getcode(si, k));
		}
		if (int(st.size()) == n) {
			cout << k << endl;
			return true;
		}
	}
	cout << -1 << endl;
	return true;
}

int main(void) {
	std::cin.tie(0)->sync_with_stdio(0);
	while (solve());
}
accuracy: 1
time_ms: 10
memory_kb: 3584
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; 0 <= i; --i)
template <typename T> bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
void solve();
int n;
string s[1<<10];
int main(){
  cin.tie(nullptr)->sync_with_stdio(false);
  cout << fixed << setprecision(20);
  int t = 1;
  //cin >> t;
  while (1) {
    cin>>n;
    if(n==0)break;
    rep(i,n)cin>>s[i];
    solve();
  }
}
bool is_boin(char ch){
  string boin="aiueo";
  for(char b:boin){
    if(b==ch)return 1;
  }
  return 0;
}
string encode(string s,int k=1000){
  string ret;
  int siz=s.size();
  ret=s[0];
  for(int i=0;i<siz-1;++i){
    if(is_boin(s[i])){
      ret+=s[i+1];
    }
  }
  if((int)ret.size()>k)ret=ret.substr(0,k);
  return ret;
}
void solve() {
  rep(i,n){
    for(int k=1;k<=50;++k){
      set<string>st;
      rep(i,n)st.insert(encode(s[i],k));
      if((int)st.size()==n){
        cout<<k<<'\n';
        return;
      }
    }
  }
  cout<<-1<<'\n';
  return;
}
accuracy: 1
time_ms: 390
memory_kb: 3712
final_rank: 20

code_snippet: /*
https://atcoder.jp/contests/abc305/tasks/abc305_a
*/
#pragma GCC optimize("O3")
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <set>
#include <tuple>
#include <map>
#include <math.h>
#include <string>
#include <cstdlib>
#include <iomanip> //出力桁数
#include <queue> // queue
#include <stack> // stack
#include <deque> // deque
#include <sstream> //基数変換
#include <bitset> //2進数に変換
#include <iterator> // set intersection
#include <numeric> // accumulate
#include <random>


using namespace std;

double pi = 3.14159265358979323846;
string yes = "Yes";
string no = "No";
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string Alpahbet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define yesno(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repp(i, l, r) for (int i = l; i < r; ++i)
#define rrep(i, r, l) for (int i = r; i >= l; --i)
#define tp() cout << "here~~" << endl
#define el '\n'
#define int long long

int INF = 1001001001;
int INFL = 4004004003094073385LL;

const int dx[4] = {1, 0, -1, 0};//グリッド上の探索
const int dy[4] = {0, 1, 0, -1};//上下左右移動方向
const int dxdi[4] = {1, 1, -1, -1};//グリッド上の探索
const int dydi[4] = {1, -1, 1, -1};//斜め移動方向

//型エイリアス vector<set<pair<tuple : bool<char<string<int<double
using ld = long double;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vi = vector<int>;
using vd = vector<double>;
using ss = set<string>;
using si = set<int>;
using msi = multiset<int>;
using mss = multiset<string>;
using pii = pair<int, int>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using vvi = vector<vector<int>>;
using vvd = vector<vector<double>>;
using vsi = vector<set<int>>;
using vpii = vector<pair<int, int>>;
using spii = set<pair<int, int>>;

using stst = stringstream;

// [ノード][(接続ノード, 重み)]
using Graph = vector<vector<int>>;//重みなしグラフ構造
using GraphWeight = vector<vector<pair<int,int>>>;//重みありグラフ構造
using GraphCh = vector<vector<char>>;//charGridの探索
using GraphIn = vector<vector<int>>;//charGridの探索
using GridPos = pair<int, int>;//グリッド上の位置・座標

//関数定義群
void put_vvc(GraphCh &, bool);
void put_vvi(vvi &, bool);
void put_vi(vi &, bool);
void put_vpii(vpii &, bool);
vector<pair<int, int> > prime_factorize(int); //素因数分解
bool contain_string(string, string); //部分文字列の一致判定
int gcd(int, int); //最大公約数
int lcm(int, int); //最小公倍数
int powll(int, int); //llの累乗
bool in_table(int, int); //添え字が１次元配列内か判定
bool in_table(int, int, int, int); //添え字が２次元配列内か判定
int modPow(int, int, int);
int modInv(int, int);
bool is_prime(int);



//cerr

string make(string t, int k) {
    string ret = "";
    ret.push_back(t[0]);
    set<char> boin = {'a', 'i', 'u', 'e', 'o'};
    rep(i, t.size()) {
        if (boin.count(t[i]) && i+1 < t.size()) {
            ret.push_back(t[i+1]);
        }
        if (ret.size() >= k) break;
    }
    return ret;
}

int solver(vs &s, int n) {
    int ans = -1;
    for (int k=1; k<=50; ++k) {
        //kでできるか判定；
        set<string> ss;
        rep(i, n) ss.insert(make(s[i], k));
        if (ss.size() == n) {
            ans = k;
            break;
        }
    }
    return ans;
}

signed main() {
    while(true) {
        int n;
        cin >> n;
        if (n == 0) break;
        vs s(n);
        rep(i, n) {
            cin >> s[i];
        }
        int ans = solver(s, n);
        cout << ans << endl;
    }
}


// signed main() {
//     int a, b, c, d, e, f, x, y;
//     string s, t;
//     int n, m, k;
//     vi va, vb, vc, vd, vx, vy;
//     // cin >>
// }




/*
n - x = mk
x = n - mk


*/














//関数群---------------------------------------------------

void put_vvc(GraphCh &g, bool bl = false) {
    int h = g.size(), w = g[0].size();
    if (bl) {
        rep(i, 10) cout << "=";
        cout << el;
    }
    rep(i, h) {
        rep(j, w) {
            cout << g[i][j];
        }
        cout << el;
    }
    if (bl) {
        rep(i, 10) cout << "=";
        cout << el;
    }
}

void put_vvi(vvi &need, bool bl = false) {
    int h = need.size();
    if (bl) {
        rep(i, 10) cout << "=";
        cout << el;
    }
    rep(i, h) {
        int w = need[i].size();
        rep(j, w) {
            if (need[i][j] >= 0) cout << ' ';
            cout << need[i][j] << ' ';
        }
        cout << el;
    }
    rep(i, 10) cout << "=";
    cout << el;
}

void put_vi(vi &v, bool bl = false) {
    if (bl) {
        rep(i, 10) cout << "=";
        cout << el;
    }
    for (auto x: v) {
        cout << x << ' ';
    }
    cout << el;
    if (bl) {
        rep(i, 10) cout << "=";
        cout << el;
    }
}

void put_vpii(vpii &v, bool bl = false) {
    if (bl) {
        rep(i, 10) cout << "=";
        cout << el;
    }
    for (auto x: v) cout << x.first << ' ' << x.second << el;
    if (bl) {
        rep(i, 10) cout << "=";
        cout << el;
    }
}
// 素因数分解
// 460 = 2^2 x 5 x 23 の場合
// 返り値は {{2, 2}, {5, 1}, {23, 1}}
vpii prime_factorize(int N) {
    // 答えを表す可変長配列
    vpii res;

    // √N まで試し割っていく
    for (int p = 2; p * p <= N; ++p) {
        // N が p で割り切れないならばスキップ
        if (N % p != 0) {
            continue;
        }

        // N の素因数 p に対する指数を求める
        int e = 0;
        while (N % p == 0) {
            // 指数を 1 増やす
            ++e;

            // N を p で割る
            N /= p;
        }

        // 答えに追加
        res.emplace_back(p, e);
    }

    // 素数が最後に残ることがありうる
    if (N != 1) {
        res.emplace_back(N, 1);
    }
    return res;
}

//文字列sにtが含まれているかを判定する
// s.size() >= t.size()に注意
bool contain_string(string s, string t) {
    if ((int)s.size() < (int)t.size()) {
        return false;
    }
    int cnt;
    for (int i=0;i<(int)s.size(); i++) {
        cnt = 0;
        for (int j = 0; j<(int)t.size(); j++) {
            if (i+j <(int)s.size() && s[i+j] == t[j]) {
                cnt ++;
            }
        }
        if (cnt == (int)t.size()) {
            return true;
        }
    }
    return false;
}

int gcd(int a, int b) {
    if (a < b) {
        int tmp = a;
        a = b;
        b = tmp;
    }
    while(b) {
        int aa = b;
        int bb = a%b;
        a = aa;
        b = bb;
    }
    return a;
}
int lcm(int a, int b) {
    return a*b/gcd(a, b);
}
int powll(int a, int b) {
    int k = 1;
    rep(i, b) {
        k *= a;
    }
    return k;
}
bool in_table(int i, int h) {
    if (i<0 || i>=h) {
        return false;
    } else {
        return true;
    }
}
bool in_table(int i, int j, int h, int w) {
    if (i<0 || i>=h || j<0 || j>=w) {
        return false;
    }
    return true;
}


int modPow(int a, int n, int mod) {
    int res = 1;
    while(n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int modInv(int a, int mod) {
    return modPow(a, mod-2, mod);
}
bool is_prime(int n) {
    if (n < 2) return false;
    for (int i=2; i<=sqrt(n); ++i) if (n % i == 0) return false;
    return true;
}

/*
-----
---------------
-------------------------
---------------
-----
*/

//Union Find
// struct UnionFind {//頂点数N, クエリ数Q -> O(Q log N)
//     vi p; //自分の親を管理
//     vi r;
//     UnionFind(int n) { //コンストラクタ インスタンス生成時に初期化
//         p.resize(n);
//         rep(i, n) {
//             p[i] = i;
//         }
//         r.resize(n, 1);
//     }
//     int find(int x) { // 均し計算量O(log N)
//         if (p[x] == x) return x;
//         else return p[x] = find(p[x]);//パス圧縮　自分の親を代表元に張りなおす
//     }
//     void unite(int x, int y) {
//         x = find(x);
//         y = find(y);
//         if (x == y) return;
//         if (r[x] > r[y]) {// Union by rank
//             swap(x, y);
//         }
//         if (r[x] == r[y]) {
//             ++r[y];
//         }
//         p[x] = y;
//     }
// };




// vb seen;
// void dfs (const Graph &G, int v) {
//     seen[v] = true;
//     //cout << "v = " << v+1 << el;
//     for (auto nextv : G[v]) {
//         if (seen[nextv] == true) {
//             continue;
//         }
//         dfs(G, nextv);
//     }
// }

// vi dist;
// int bfs (const Graph &G, int v) {
//     queue<int> que;
//     dist[v] = 0;
//     que.push(v);
//     while(!que.empty()) {
//         v = que.front();
//         que.pop();
//         // cout << "v = " << v+1 << el;
//         for(int nv: G[v]) {
//             if (dist[nv] == -1) {
//                 dist[nv] = dist[v] + 1;
//                 que.push(nv);
//             } else {
//                 //tuiki
//                 continue;
//             }
//         }
//     }
//     return 0;
// }
accuracy: 1
time_ms: 10
memory_kb: 3360
final_rank: 3

code_snippet: #include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,s,t) for(ll i=s;i<(ll)(t);i++)
#define rrep(i,s,t) for(ll i=(ll)(t)-1;i>=(ll)s;i--)
#define all(x) begin(x),end(x)
#define rall(x) rbegin(x),rend(x)

#define TT template<typename T>
TT using vec=vector<T>;
TT bool chmin(T &x,T y){return x>y?(x=y,true):false;}
TT bool chmax(T &x,T y){return x<y?(x=y,true):false;}

struct io_setup{
    io_setup(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        cout<<fixed<<setprecision(15);
    }
} io_setup;

const string cs="aiueo";

int solve(){
    int N;
    cin>>N;
    if(N==0)return 0;
    vector<string>S(N);
    for(int i=0;i<N;i++){
        string s;
        cin>>s;
        int l=s.size();
        S[i]+=s[0];
        for(int j=0;j<l-1;j++){
            for(int k=0;k<5;k++){
                if(cs[k]==s[j]){
                    S[i]+=s[j+1];
                }
            }
        }
    }
    for(int k=1;k<=55;k++){
        bool ok=true;
        for(int i=0;i<N-1;i++){
            for(int j=i+1;j<N;j++){
                if(S[i].substr(0,min(k,(int)S[i].size()))==S[j].substr(0,min(k,(int)S[j].size()))){
                    ok=false;
                    break;
                }
            }
        }
        if(ok){
            cout<<k<<"\n";
            return 1;
        }
    }
    cout<<-1<<"\n";
    return 1;
}

int main(){
    while(solve());
}
accuracy: 1
time_ms: 10
memory_kb: 3476
final_rank: 7

code_snippet: #ifdef RELEASE
#pragma GCC target("arch=x86-64-v3")
#pragma GCC optimize("Ofast")
#endif

#include <bits/stdc++.h>

//#include <atcoder/all>


using namespace std;

using ll = long long;
using i64 = long long;

constexpr ll mod = 998244353;


int main(){
  while (true){
    int n;
    cin >> n;
    if(n == 0)break;
    vector<string> v(n);
    for(int i = 0; i < n; ++i){
      cin >> v[i];
    }
    vector<string> w(n);
    for(int i = 0; i < n; ++i){
      auto& s = v[i];
      bool fl = true;
      for(int j = 0; j < s.size(); ++j){
        if(fl){
          w[i] += s[j];
        }
        string cons = "aiueo";
        if(cons.find(s[j]) != string::npos){
          fl = true;
        }
        else{
          fl = false;
        }
      }
    }
    int ans = 1000;
    for(int i = 1; i < 1000; ++i){
      set<string> se;
      for(int j = 0; j < n; ++j){
        string t;
        for(int k = 0; k < min(i, int(w[j].size())); ++k){
          t += w[j][k];
        }
        se.emplace(t);
      }
      if(se.size() == n){
        ans = i; break;
      }
    }
    cout << (ans == 1000 ? -1 : ans) << endl;
  }
}
accuracy: 1
time_ms: 40
memory_kb: 3360
final_rank: 18

code_snippet: #include<bits/stdc++.h>
using namespace std;
string code(const string& s, int k)
{
    string t;
    t.push_back(s[0]);
    for(int i=1;i<s.size();i++)
    {
        if(t.size()==k)return t;
        if([&]
        {
            for(char c:"aeiou")if(s[i-1]==c)return 1;
            return 0;
        }())t.push_back(s[i]);
    }
    return t;
}
bool solve()
{
    int N;
    cin>>N;
    if(N==0)return 0;
    vector<string>S(N);
    for(int i=0;i<N;i++)cin>>S[i];
    int ans=1<<30;
    for(int k=1;k<=50;k++)
    {
        set<string>codes;
        bool ok=1;
        for(string s:S)
        {
            string T=code(s,k);
            if(codes.count(T))ok=0;
            codes.insert(T);
        }
        if(ok)
        {
            ans=k;
            break;
        }
    }
    if(ans==1<<30)ans=-1;
    cout<<ans<<'\n';
    return 1;
}
int main(){while(solve()){}}
accuracy: 1
time_ms: 10
memory_kb: 3332
final_rank: 2

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, a, b) for(ll i = a; i < b; ++i)
#define rrep(i, a, b) for(ll i = a; i >= b; --i)
constexpr ll inf = 4e18;

string f(string s, ll k) {
    ll n = s.size();
    string res = "";
    set<char> st;
    st.insert('a');
    st.insert('i');
    st.insert('u');
    st.insert('e');
    st.insert('o');
    res += s[0];
    rep(i,0,n-1) {
        if(st.find(s[i]) != st.end()) {
            res += s[i + 1];
        }
    }
    if((ll)res.size() <= k) {
        return res;
    } else {
        string ans = "";
        rep(i,0,k){
            ans += res[i];
        }
        return ans;
    }
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
    while(1) {
        ll n;cin>>n;
        if(n == 0)break;
        vector<string> s(n);
        rep(i,0,n)cin>>s[i];
        ll ans = -1;
        rep(k,1,52) {
            set<string> st;
            rep(i,0,n){
                st.insert(f(s[i], k));
            }
            // cerr << k << endl;
            // for (auto it : st) {
            //     cerr << it << "\n";
            // }
            // cerr << "\n";
            if((ll)st.size() == n){
                ans = k;
                break;
            }
        }
        cout << ans << "\n";
    }
}
accuracy: 1
time_ms: 20
memory_kb: 3412
final_rank: 16

code_snippet: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int N;
string S[1 << 18];
string T[1 << 18];

int main() {
	while (true) {
		// Step 1. Input
		cin >> N; if (N == 0) break;
		for (int i = 0; i < N; i++) cin >> S[i];
		for (int i = 0; i < N; i++) T[i] = "";

		// Step 2. Simple
		for (int i = 0; i < N; i++) {
			T[i] += S[i][0];
			for (int j = 0; j < S[i].size() - 1; j++) {
				char c = S[i][j];
				if (c != 'a' && c != 'i' && c != 'u' && c != 'e' && c != 'o') continue;
				T[i] += S[i][j + 1];
			}
		}

		// Step 3. Brute Force
		int Answer = (1 << 30);
		for (int i = 1; i <= 100; i++) {
			vector<string> V;
			for (int j = 0; j < N; j++) {
				V.push_back(T[j].substr(0, min((int)T[j].size(), i)));
			}
			sort(V.begin(), V.end());
			V.erase(unique(V.begin(), V.end()), V.end());
			if (V.size() == N) Answer = min(Answer, i);
		}

		// Step 4. Output
		if (Answer == (1 << 30)) cout << "-1" << endl;
		else cout << Answer << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 19736
final_rank: 19

code_snippet: #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        vector<string> s(n);
        for (int i = 0; i < n; i++) {
            cin >> s[i];
        }
        int ans = 51;
        for (int i = 1; i <= 50; i++) {
            bool pos = true;
            vector<string> ss(0);
            for (int j = 0; j < n; j++) {
                string sss = "";
                for (int k = 0; k < s[j].size(); k++) {
                    if (sss.size() == i) {
                        break;
                    } else if (k == 0) {
                        sss += s[j][k];
                    } else if (s[j][k - 1] == 'a' || s[j][k - 1] == 'i' ||
                               s[j][k - 1] == 'u' || s[j][k - 1] == 'e' ||
                               s[j][k - 1] == 'o') {
                        sss += s[j][k];
                    }
                }
                ss.push_back(sss);
            }
            if (!pos) {
                continue;
            }
            /*for (int j = 0; j < ss.size(); j++) {
                cout << ss[j] << " ";
            }
            cout << endl;*/
            sort(ss.begin(), ss.end());
            for (int j = 0; j < ss.size() - 1; j++) {
                if (ss[j] == ss[j + 1]) {
                    pos = false;
                }
            }
            if (pos) {
                ans = min(ans, i);
            }
        }
        if (ans == 51) {
            cout << -1 << endl;
        } else {
            cout << ans << endl;
        }
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3404
final_rank: 5

code_snippet: #line 2 "src/cp-template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull  = unsigned long long;
using i128 = __int128_t;
template < class T > bool chmin(T& a, T b) { if(a > b) { a = b; return true; } return false; }
template < class T > bool chmax(T& a, T b) { if(a < b) { a = b; return true; } return false; }

#line 2 "src/utility/rep_itr.hpp"
template < class T > struct itr {
    T i, d;
    constexpr itr(const T i) noexcept : i(i), d(1) {}
    constexpr itr(const T i, const T d) noexcept : i(i), d(d) {}
    void operator++() noexcept { i += d; }
    constexpr int operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept {
        return d > 0 ? i < x.i : i > x.i;
    }
};

template < class T > struct rep {
    const itr< T > s, t;
    constexpr rep(const T t) noexcept : s(0), t(t) {}
    constexpr rep(const T s, const T t) noexcept : s(s), t(t) {}
    constexpr rep(const T s, const T t, const T d) noexcept : s(s, d), t(t, d) {}
    constexpr auto begin() const noexcept { return s; }
    constexpr auto end() const noexcept { return t; }
};

template < class T > struct revrep {
    const itr < T > s, t;
    constexpr revrep(const T t) noexcept : s(t - 1, -1), t(-1, -1) {}
    constexpr revrep(const T s, const T t) noexcept : s(t - 1, -1), t(s - 1, -1) {}
    constexpr revrep(const T s, const T t, const T d) noexcept : s(t - 1, -d), t(s - 1, -d) {}
    constexpr auto begin() const noexcept { return s; }
    constexpr auto end() const noexcept { return t; }
};
#line 2 "src/utility/io.hpp"
namespace scanner {
    struct sca {
        template < class T > operator T() {
            T s; cin >> s; return s;
        }
    };
    struct vec {
        int n;
        vec(int n) : n(n) {}
        template < class T > operator vector< T >() {
            vector< T > v(n);
            for(T& x : v) cin >> x;
            return v;
        }
    };
    struct mat {
        int h,w;
        mat(int h, int w) : h(h), w(w) {}
        template < class T > operator vector< vector< T > >() {
            vector m(h, vector< T >(w));
            for(vector< T >& v : m) for(T& x : v) cin >> x;
            return m;
        }
    };
    struct speedup {
        speedup() {
            cin.tie(0);
            ios::sync_with_stdio(0);
        }
    } su;
}
scanner::sca in() { return scanner::sca(); }
scanner::vec in(int n) { return scanner::vec(n); }
scanner::mat in(int h, int w) { return scanner::mat(h, w); }

namespace printer {
    void precision(int d) {
        cout << fixed << setprecision(d);
    }
    void flush() {
        cout.flush();
    }
}
int print() { cout << '\n'; return 0; }
template < class head, class... tail > int print(head&& h, tail&&... t) {
    cout << h; if(sizeof...(tail)) cout << ' ';
    return print(forward<tail>(t)...);
}
template < class T > int print(vector< T > a, char sep = ' ') {
    int n = a.size();
    for(int i : rep(n)) cout << a[i] << (i != n - 1 ? sep : '\n');
    return 0;
}
template < class T > int print(vector< vector< T > > a) {
    if(a.empty()) return 0;
    int h = a.size(), w = a[0].size();
    for(int i : rep(h)) for(int j : rep(w)) cout << a[i][j] << (j != w - 1 ? ' ' : '\n');
    return 0;
}
#line 2 "src/utility/key_val.hpp"
template < class K, class V >
struct key_val {
    K key; V val;
    key_val() {}
    key_val(K key, V val) : key(key), val(val) {}
};
#line 2 "src/utility/vec_op.hpp"
template < class T >
key_val< int, T > max_of(const vector< T >& a) {
    int i = max_element(a.begin(), a.end()) - a.begin();
    return {i, a[i]};
}

template < class T >
key_val< int, T > min_of(const vector< T >& a) {
    int i = min_element(a.begin(), a.end()) - a.begin();
    return {i, a[i]};
}

template < class T >
T sum_of(const vector< T >& a) {
    T sum = 0;
    for(const T x : a) sum += x;
    return sum;
}

template < class T >
vector<ll> freq_of(const vector< T >& a, T L, T R) {
    vector<ll> res(R - L);
    for(const T x : a) res[x - L]++;
    return res;
}

template < class T >
vector<ll> freq_of(const vector< T >& a, T R) {
    return freq_of(a, T(0), R);
}

template < class T >
struct prefix_sum {
    vector< T > s;
    prefix_sum(const vector< T >& a) : s(a) {
        s.insert(s.begin(), T(0));
        for(int i : rep(a.size())) s[i + 1] += s[i];
    }
    // [L, R)
    T sum(int L, int R) {
        return s[R] - s[L];
    }
};
#line 2 "A.cpp"

int main() {
    while(true) {
        int n = in(); if(n == 0) break;
        vector<string> s = in(n);
        auto f = [&](char c) {
            if(set<char>{'a', 'i', 'u', 'e', 'o'}.count(c)) return 1;
            return 0;
        };
        for(int i : rep(n)) {
            string t = "";
            for(int j : rep(s[i].size())) {
                if(j == 0) t += s[i][j];
                else if(f(s[i][j - 1])) t += s[i][j];
            }
            s[i] = t;
        }

        const int MAX_K = 50;
        int ans = MAX_K + 1;
        for(int k = 0; k <= MAX_K; k++) {
            set<string> st;
            for(int i : rep(n)) {
                if(s[i].size() < k) {
                    st.insert(s[i]);
                } else {
                    st.insert(s[i].substr(0, k));
                }
            }

            if(st.size() == n) chmin(ans, k);
        }
        print(ans == MAX_K + 1 ? -1 : ans);
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3484
final_rank: 8

code_snippet: # include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using ld = long double;
const ll INF = (1LL << 60);
# define ov3(_1, _2, _3, name, ...) name
# define rep1(n) rep2(_,n)
# define rep2(i,n) rep3(i,0,n)
# define rep3(i,a,b) for(ll i = a; i < ll(b); i++)
# define rep(...) ov3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
# define all(v) std::begin(v), std::end(v)
# define first fs
# define second sc
# define vec(a, T) using v##a = vector<T>; using vv##a = vector<v##a>; using vvv##a = vector<vv##a>
vec(ll, ll);
vec(ld, ld);
vec(pll, pll);
vec(b, bool);

template <class T> bool chmin(T& a, T b) { return a > b && (a = b, true); }
template <class T> bool chmax(T& a, T b) { return a < b && (a = b, true); }

int main() {
   while (true) {
      int n;
      cin >> n;
      if (!n) break;
      vector<string> s(n);
      rep (i, n) cin >> s[i];

      string aiueo = "aiueo";

      vector<string> t(n);
      rep (i, n) {
         int j = 0;
         t[i].push_back(s[i][j]);
         const int m = s[i].size();
         while (j < m) {
            if (aiueo.find(s[i][j]) != string::npos) {
               if (j + 1 < m) {
                  t[i].push_back(s[i][j + 1]);
               }
            }
            j++;
         }
      }

      ll ans = INF;
      rep (k, 100) {
         set<string> st;
         rep (i, n) {
            if ((int)t[i].size() < k) {
               st.insert(t[i]);
            }
            else {
               st.insert(t[i].substr(0, k));
            }
         }
         if ((int)st.size() == n) {
            chmin(ans, k);
         }
      }

      if (ans == INF) cout << "-1" << endl;
      else cout << ans << endl;
   }
}
accuracy: 1
time_ms: 10
memory_kb: 3420
final_rank: 6

code_snippet: #include<bits/stdc++.h>
using namespace std;

string trim(string s,int k){
  string res = "";
  bool use = true;
  set<char> b;
  b.insert('a');
  b.insert('i');
  b.insert('u');
  b.insert('e');
  b.insert('o');
  for(auto i:s){
    if(use){
      res += i;
      use = false;
    }
    if(b.count(i)){
      use = true;
    }
  }
  return res.substr(0,k);
}

int func(int n){
  vector<string> line(n);
  for(auto &i:line)cin >> i;

  for(int i=0;i<100;++i){
    set<string> ss;
    for(auto j:line)ss.insert(trim(j,i));
    if(ss.size()==n)return i;
  }
  return -1;
}

int main(){
  int n;
  while(cin >> n && n){
    cout << func(n) << endl;
  }
}
accuracy: 1
time_ms: 40
memory_kb: 3352
final_rank: 17

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;
template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
    os << "[ ";
    for (auto &vi : v) os << vi << " ";
    return os << "]";
}
#define show(x) cerr << #x << " = " << x << endl;
// #define show(x) true

void solve(int N) {
    vector<string> S(N);
    REP(i, N) cin >> S[i];
    for (int k = 1; k < 100; k++) {
        auto f = [](string s, int k) -> string {
            int len = (int)s.size();
            string t;
            string v = "aiueo";
            for (int i = 0; i < len; i++) {
                if (i == 0) {
                    t += s[i];
                } else {
                    int find = 0;
                    REP(j, 5) if (s[i - 1] == v[j]) find = 1;
                    if (find) {
                        t += s[i];
                    }
                }
            }
            return t.substr(0, k);
        };
        set<string> st;
        for (auto &si : S) st.insert(f(si, k));
        if (st.size() == S.size()) {
            cout << k << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main() {
    int N;
    while (cin >> N, !(N == 0)) solve(N);
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3236
final_rank: 12

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;
template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
    os << "[ ";
    for (auto &vi : v) os << vi << " ";
    return os << "]";
}
#define show(x) cerr << #x << " = " << x << endl;
// #define show(x) true

void solve(int N) {
    vector<string> S(N);
    REP(i, N) cin >> S[i];
    for (int k = 1; k < 100; k++) {
        auto f = [](string s, int k) -> string {
            int len = (int)s.size();
            string t;
            string v = "aiueo";
            for (int i = 0; i < len; i++) {
                if (i == 0) {
                    t += s[i];
                } else {
                    int find = 0;
                    REP(j, 5) if (s[i - 1] == v[j]) find = 1;
                    if (find) {
                        t += s[i];
                    }
                }
            }
            return t.substr(0, k);
        };
        set<string> st;
        for (auto &si : S) st.insert(f(si, k));
        if (st.size() == S.size()) {
            cout << k << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main() {
    int N;
    while (cin >> N, !(N == 0)) solve(N);
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3160
final_rank: 11

code_snippet: #include <bits/stdc++.h>

using namespace std;
using ll = long long;

int ini() {
    int n;
    cin >> n;
    return n;
}


void solve(int n) {
    vector<string> s(n);
    vector<string> t(n);
    int ml = 0;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        for (int j = 0; j < (int)s[i].size(); j++) {
            if (j == 0 || s[i][j-1] == 'a' || s[i][j-1] == 'i' || s[i][j-1] == 'u' || s[i][j-1] == 'e' || s[i][j-1] == 'o') {
                t[i].push_back(s[i][j]);
            }
        }
        ml = max(ml, (int)t[i].size());
    }
    for (int k = 1; k <= ml; k++) {
        bool ok = true;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (i == j) {
                    continue;
                }
                bool same = true;
                for (int l = 0; l < k; l++) {
                    same &= (l < t[i].size() ? t[i][l] : 0) == (l < t[j].size() ? t[j][l] : 0);
                }
                if (same) {
                    ok = false;
                }
            }
        }
        if (ok) {
            cout << k << endl;
            return;
        }
    }
    cout << "-1" << endl;
}

int main(){
    while(true){
        int n = ini();
        if(n == 0){
            break;
        }
        solve(n);
    }
}
accuracy: 1
time_ms: 20
memory_kb: 3408
final_rank: 15

code_snippet: #include<bits/stdc++.h>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define ALL(a)  (a).begin(),(a).end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int)x.size())

using namespace std;
using ld = long double;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;

const ll ZER = 0;
const ll MOD = 998244353;

int main() {
    int n;
    while(cin >> n){
        if(n == 0)break;
        vector<string> s;
        rep(i, n){
            string ss;
            cin >> ss;
            string ps = "";
            ps.pb(ss[0]);
            REP(i, 0, sz(ss)-1){
                char c = ss[i];
                if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
                    if(i+1 < sz(ss))ps.pb(ss[i+1]);
                }
            }
            s.pb(ps);
        }
        // for(auto si : s)cout << si << ", ";cout << endl;
        // kを求める
        int k = 1;
        bool f = true;
        int maxsz = -1;
        rep(i, n)chmax(maxsz, sz(s[i]));
        // cout << "maxsz = " << maxsz << endl;
        while(f && k <= maxsz){
            f = false;
            rep(i, n){
                REP(j, i+1, n-1){
                    string si, sj;
                    if(sz(s[i]) > k)si = s[i].substr(0, k);
                    else si = s[i];
                    if(sz(s[j]) > k)sj = s[j].substr(0, k);
                    else sj = s[j];

                    if(si == sj)f = true;
                    // cout << si << " " << sj << endl;
                }
            }
            // 同じものがあった
            if(f){
                k++;
            }
            else {
                break;
            }
        }
        if(maxsz < k)k = -1;
        cout << k << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3368
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define all(a)  (a).begin(),(a).end()
#define rall(a)  (a).rbegin(),(a).rend()
typedef long long ll;
typedef pair<ll,ll> pl;

char c[5]={'a','i','u','e','o'};

int main() {
    while(true) {
        int n;
        cin >> n;
        if(n==0) break;
        vector<string> s(n);
        rep(i,n) cin >> s[i];
        vector<string> code;
        int x=0;
        rep(i,n) {
            string str;
            str+=s[i][0];
            rep(j,(int)s[i].size()) {
                rep(k,5) if(s[i][j]==c[k]) {
                    if(j<(int)s[i].size()-1) str+=s[i][j+1];
                } 
            }
            code.push_back(str);
            x=max(x,(int)str.size());
        }
        int ans=100;
        for(int i=1;i<=x;i++) {
            map<string,int> m;
            bool flag=true;
            rep(j,n) {
                if(m[code[j].substr(0,i)]!=0) flag=false;
                m[code[j].substr(0,i)]++;
            }
            if(flag) ans=min(ans,i);
        }
        if(ans==100) ans=-1;
        cout << ans << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3192
final_rank: 1

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()

int f(int n){
  vector<string> s(n);
  REP(i,n)cin>>s[i];
  set<char>L{'a','i','u','o','e'};
  for(int k=1;k<=50;k++){
    set<string> se;
    REP(i,n){
      string t;
      t+=s[i][0];
      REP(j,s[i].size()-1)if(L.count(s[i][j]))t+=s[i][j+1];
      t=t.substr(0,k);
      se.insert(t);
    }
    //cout<<"K:"<<k<<endl;
    //for(string p:se)cout<<p<<" ";cout<<endl;
    if(se.size()==n)return k;
  }
  return -1;
}

int main(){
  int n;
  while(cin>>n,n)cout<<f(n)<<endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3396
final_rank: 14

code_snippet: #ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
 
#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
 
#pragma region Macros
// rep macro
#define foa(v, a) for(auto &v : a)
#define REPname(a, b, c, d, e, ...) e
#define REP(...) REPname(__VA_ARGS__, REP3, REP2, REP1, REP0)(__VA_ARGS__)
#define REP0(x) for(int i = 0; i < (x); ++i)
#define REP1(i, x) for(int i = 0; i < (x); ++i)
#define REP2(i, l, r) for(int i = (l); i < (r); ++i)
#define REP3(i, l, r, c) for(int i = (l); i < (r); i += (c))
#define REPSname(a, b, c, ...) c
#define REPS(...) REPSname(__VA_ARGS__, REPS1, REPS0)(__VA_ARGS__)
#define REPS0(x) for(int i = 1; i <= (x); ++i)
#define REPS1(i, x) for(int i = 1; i <= (x); ++i)
#define RREPname(a, b, c, d, e, ...) e
#define RREP(...) RREPname(__VA_ARGS__, RREP3, RREP2, RREP1, RREP0)(__VA_ARGS__)
#define RREP0(x) for(int i = (x)-1; i >= 0; --i)
#define RREP1(i, x) for(int i = (x)-1; i >= 0; --i)
#define RREP2(i, l, r) for(int i = (r)-1; i >= (l); --i)
#define RREP3(i, l, r, c) for(int i = (r)-1; i >= (l); i -= (c))
#define RREPSname(a, b, c, ...) c
#define RREPS(...) RREPSname(__VA_ARGS__, RREPS1, RREPS0)(__VA_ARGS__)
#define RREPS0(x) for(int i = (x); i >= 1; --i)
#define RREPS1(i, x) for(int i = (x); i >= 1; --i)
 
// name macro
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define popcnt(x) __builtin_popcountll(x)
template <class T = int>
using V = std::vector<T>;
template <class T = int>
using VV = std::vector<std::vector<T>>;
template <class T = int>
using VVV = std::vector<std::vector<std::vector<T>>>;
template <class T>
using pqup = std::priority_queue<T, std::vector<T>, std::greater<T>>;
using ll = long long;
using ld = long double;
using int128 = __int128_t;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using Tp = tuple<ll,ll,ll>;
 
// input macro
template <class T, class U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
	is >> p.first >> p.second;
	return is;
}
template <class T>
std::istream &operator>>(std::istream &is, std::vector<T> &v) {
	for(T &i : v) is >> i;
	return is;
}
std::istream &operator>>(std::istream &is, __int128_t &a) {
	std::string s;
	is >> s;
	__int128_t ret = 0;
	for(int i = 0; i < s.length(); i++)
		if('0' <= s[i] and s[i] <= '9')
			ret = 10 * ret + s[i] - '0';
	a = ret * (s[0] == '-' ? -1 : 1);
	return is;
}
namespace scanner {
void scan(int &a) { std::cin >> a; }
void scan(long long &a) { std::cin >> a; }
void scan(std::string &a) { std::cin >> a; }
void scan(char &a) { std::cin >> a; }
void scan(char a[]) { std::scanf("%s", a); }
void scan(double &a) { std::cin >> a; }
void scan(long double &a) { std::cin >> a; }
template <class T, class U>
void scan(std::pair<T, U> &p) { std::cin >> p; }
template <class T>
void scan(std::vector<T> &a) { std::cin >> a; }
void INPUT() {}
template <class Head, class... Tail>
void INPUT(Head &head, Tail &... tail) {
	scan(head);
	INPUT(tail...);
}
}  // namespace scanner
#define VEC(type, name, size)     \
	std::vector<type> name(size); \
	scanner::INPUT(name)
#define VVEC(type, name, h, w)                                    \
	std::vector<std::vector<type>> name(h, std::vector<type>(w)); \
	scanner::INPUT(name)
#define INT(...)     \
	int __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define LL(...)            \
	long long __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define STR(...)             \
	std::string __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define CHAR(...)     \
	char __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define DOUBLE(...)     \
	double __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define LD(...)              \
	long double __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
 
// output-macro
template <class T, class U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &p) {
	os << p.first << " " << p.second;
	return os;
}
template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &a) {
	for(int i = 0; i < int(a.size()); ++i) {
		if(i) os << " ";
		os << a[i];
	}
	return os;
}
std::ostream &operator<<(std::ostream &dest, __int128_t &value) {
	std::ostream::sentry s(dest);
	if(s) {
		__uint128_t tmp = value < 0 ? -value : value;
		char buffer[128];
		char *d = std::end(buffer);
		do {
			--d;
			*d = "0123456789"[tmp % 10];
			tmp /= 10;
		} while(tmp != 0);
		if(value < 0) {
			--d;
			*d = '-';
		}
		int len = std::end(buffer) - d;
		if(dest.rdbuf()->sputn(d, len) != len) {
			dest.setstate(std::ios_base::badbit);
		}
	}
	return dest;
}
template <class T>
void print(const T a) { std::cout << a << '\n'; }
template <class Head, class... Tail>
void print(Head H, Tail... T) {
	std::cout << H << ' ';
	print(T...);
}
template <class T>
void printel(const T a) { std::cout << a << '\n'; }
template <class T>
void printel(const std::vector<T> &a) {
	for(const auto &v : a)
		std::cout << v << '\n';
}
template <class Head, class... Tail>
void printel(Head H, Tail... T) {
	std::cout << H << '\n';
	printel(T...);
}
void Yes(const bool b = true) { std::cout << (b ? "Yes\n" : "No\n"); }
void No() { std::cout << "No\n"; }
void YES(const bool b = true) { std::cout << (b ? "YES\n" : "NO\n"); }
void NO() { std::cout << "No\n"; }
void err(const bool b = true) {
	if(b) {
		std::cout << "-1\n", exit(0);
	}
}
 
//debug macro
namespace debugger {
template <class T>
void view(const std::vector<T> &a) {
	std::cerr << "{ ";
	for(const auto &v : a) {
		std::cerr << v << ", ";
	}
	std::cerr << "\b\b }";
}
template <class T>
void view(const std::vector<std::vector<T>> &a) {
	std::cerr << "{\n";
	for(const auto &v : a) {
		std::cerr << "\t";
		view(v);
		std::cerr << "\n";
	}
	std::cerr << "}";
}
template <class T, class U>
void view(const std::vector<std::pair<T, U>> &a) {
	std::cerr << "{\n";
	for(const auto &p : a) std::cerr << "\t(" << p.first << ", " << p.second << ")\n";
	std::cerr << "}";
}
template <class T, class U>
void view(const std::map<T, U> &m) {
	std::cerr << "{\n";
	for(const auto &p : m) std::cerr << "\t[" << p.first << "] : " << p.second << "\n";
	std::cerr << "}";
}
template <class T, class U>
void view(const std::pair<T, U> &p) { std::cerr << "(" << p.first << ", " << p.second << ")"; }
template <class T>
void view(const std::set<T> &s) {
	std::cerr << "{ ";
	for(auto &v : s) {
		view(v);
		std::cerr << ", ";
	}
	std::cerr << "\b\b }";
}
 
template <class T>
void view(const T &e) { std::cerr << e; }
}  // namespace debugger
#ifdef LOCAL
void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	debugger::view(H);
	std::cerr << ", ";
	debug_out(T...);
}
#define debug(...)                                                \
	do {                                                          \
		std::cerr << __LINE__ << " [" << #__VA_ARGS__ << "] : ["; \
		debug_out(__VA_ARGS__);                                   \
		std::cerr << "\b\b]\n";                                   \
	} while(false)
#else
#define debug(...) (void(0))
#endif
 
// vector macro
template <class T>
int lb(const std::vector<T> &a, const T x) { return std::distance((a).begin(), std::lower_bound((a).begin(), (a).end(), (x))); }
template <class T>
int ub(const std::vector<T> &a, const T x) { return std::distance((a).begin(), std::upper_bound((a).begin(), (a).end(), (x))); }
template <class T>
void UNIQUE(std::vector<T> &a) {
	std::sort(a.begin(), a.end());
	a.erase(std::unique(a.begin(), a.end()), a.end());
}
template <class T>
std::vector<T> press(std::vector<T> &a) {
	auto res = a;
	UNIQUE(res);
	for(auto &v : a)
		v = lb(res, v);
	return res;
}
#define SORTname(a, b, c, ...) c
#define SORT(...) SORTname(__VA_ARGS__, SORT1, SORT0, ...)(__VA_ARGS__)
#define SORT0(a) std::sort((a).begin(), (a).end())
#define SORT1(a, c) std::sort((a).begin(), (a).end(), [](const auto x, const auto y) { return x c y; })
template <class T>
void ADD(std::vector<T> &a, const T x) {
	for(auto &v : a) v += x;
}
template <class T>
void SUB(std::vector<T> &a, const T x = 1) {
	for(auto &v : a) v -= x;
}
template <class T>
void MUL(std::vector<T> &a, const T x) {
	for(auto &v : a) v *= x;
}
template <class T>
void DIV(std::vector<T> &a, const T x) {
	for(auto &v : a) v /= x;
}
 
// math macro
template <class T, class U>
inline bool chmin(T &a, const U &b) { return a > b ? a = b, true : false; }
template <class T, class U>
inline bool chmax(T &a, const U &b) { return a < b ? a = b, true : false; }
template <class T>
T divup(T x, T y) { return (x + y - 1) / y; }
template <class T>
T POW(T a, long long n) {
	T ret = 1;
	while(n) {
		if(n & 1) ret *= a;
		a *= a;
		n >>= 1;
	}
	return ret;
}

template<typename T>
T ADD(T a, T b){
	T res;
	return __builtin_add_overflow(a, b, &res) ? numeric_limits<T>::max() : res;
}

template<typename T>
T MUL(T a, T b){
	T res;
	return __builtin_mul_overflow(a, b, &res) ? numeric_limits<T>::max() : res;
}

// modpow
long long POW(long long a, long long n, const int mod) {
	long long ret = 1;
	while(n) {
		if(n & 1) (ret *= a) %= mod;
		(a *= a) %= mod;
		n >>= 1;
	}
	return ret;
}
 
// others
struct fast_io {
	fast_io() {
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		cout << fixed << setprecision(15);
	}
} fast_io_;

#pragma endregion

using R = long double;
constexpr R EPS=1E-11;

// r の(誤差付きの)符号に従って, -1, 0, 1 を返す.
int sgn(const R& r){ return (r > EPS) - (r < -EPS); }
// a, b の(誤差付きの)大小比較の結果に従って, -1, 0, 1 を返す.
int sgn(const R& a, const R &b){ return sgn(a-b); }
// a > 0 は sgn(a) > 0
// a < b は sgn(a, b) < 0
// a >= b は sgn(a, b) >= 0
// のように書く.
// return s * 10^n

//https://atcoder.jp/contests/abc191/submissions/20028529
long long x10(const string& s, size_t n) {
    if (s.front() == '-') return -x10(s.substr(1), n);
    auto pos = s.find('.');
    if (pos == string::npos) return stoll(s + string(n, '0'));
    return stoll(s.substr(0, pos) + s.substr(pos + 1) + string(n + pos + 1 - s.size(), '0'));
}
 
long long ceildiv(long long a, long long b) {
    if (b < 0) a = -a, b = -b;
    if (a >= 0) return (a + b - 1) / b;
    else return a / b;
}
 
long long floordiv(long long a, long long b) {
    if (b < 0) a = -a, b = -b;
    if (a >= 0) return a / b;
    else return (a - b + 1) / b;
}
 
long long floorsqrt(long long x) {
    assert(x >= 0);
    long long ok = 0;
    long long ng = 1;
    while (ng * ng <= x) ng <<= 1;
    while (ng - ok > 1) {
        long long mid = (ng + ok) >> 1;
        if (mid * mid <= x) ok = mid;
        else ng = mid;
    }
    return ok;
}

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){//popcount%2
	return __builtin_parity(x);
}

const int inf = 1e9;
const ll INF = 1e18;

void main_() {
    ll n;
    cin >> n;
    string u = "aiueo";
    while(n != 0){
        VEC(string,s,n);
        ll ans = INF;
        for(ll k = 1;k <= 50;k++){
            set<string> cnt;
            REP(i,n){
                ll m = s[i].length();
                string t = "";
                t += s[i][0];
                REP(j,m-1){
                    if(t.length() == k)break;
                    bool ex = false;
                    REP(p,5){
                        if(s[i][j] == u[p])ex = true;
                    }
                    if(ex)t += s[i][j+1];
                    
                }
                cnt.insert(t);
            }
            if(cnt.size() == n){
                ans = min(ans,k);
                break;
            }
        }
        if(ans == INF) cout << -1 << endl;
        else cout << ans << endl;
        cin >> n;
    }
    
}
 
int main() {
	int t = 1;
	//cin >> t;
	while(t--) main_();
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3496
final_rank: 9