#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(a,b) (0<=(a)&&(a)<(b))

using namespace std;

int main(){
	int n;
	while(cin>>n,n){
		string s[51];
		REP(i,0,n) {
			string tmps;
			cin>>tmps;
			s[i]+=tmps[0];
			REP(j,1,(int)tmps.size()){
				char c=tmps[j-1];
				if(c=='a'||c=='i'||c=='u'||c=='e'||c=='o'){
					s[i]+=tmps[j];
				}
			}
		}
		sort(s,s+n);
		int k=0;
		bool flag=false;
		REP(i,0,n-1){
			if(s[i]==s[i+1]) {
				flag=true;
				break;
			}
			int mn=min<int>(s[i].size(),s[i+1].size());
			REP(j,0,mn){
				if(s[i][j]!=s[i+1][j])	{
					k=max(k,j+1);
					break;
				}
				if(j==mn-1)	k=max(k,mn+1);
			}
		}
		p(flag?-1:k);
	}
	return 0;
}