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

string airport_code(string s) {
    string ret = "";
    ret += s[0];
    for (int i = 1; i < s.size(); i++) {
        for (auto c : "aiueo") {
            if (s[i - 1] == c) ret += s[i];
        }
    }
    return ret;
}

bool check_duplicate(vector<string> &codes, int k) {
    set<string> s;
    for (auto code : codes) {
        if (code.size() < k)
            s.insert(code);
        else
            s.insert(code.substr(0, k));
    }
    return (s.size() == codes.size());
}

int main() {
    int n;
    while (cin >> n, n) {
        vector<string> acode(n);
        int max_len = -1e9;
        for (int i = 0; i < n; i++) {
            string s; cin >> s;
            acode[i] = airport_code(s);
            max_len = max(max_len, (int)acode[i].size());

        }

        if (!check_duplicate(acode, max_len)){
            cout << -1 << endl;
            continue;
        }
        for (int i = 1; i <= max_len; i++) {
            if (check_duplicate(acode, i)) {
                cout << i << endl;
                break;
            }
        }
    }
}

