#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
const int MAXLEN = 1000; // максимальная длина всех строк
const int inf = 1000;
struct vertex {
map <char, int> next;
bool leaf;
};
int sz, len;
vertex tr[MAXLEN];
void init_trie () {
sz = 0;
for (int i = 0; i < MAXLEN; ++i) {
tr[i].next.clear ();
tr[i].leaf = false;
}
sz++;
}
void add_string (string s) {
int v = 0;
for (int i = 0; i < s.length (); ++i) {
if (!tr[v].next.count (s[i])) {
tr[v].next[s[i]] = sz++;
}
if (tr[v].next.size () > 1) {
len = min(len, i);
}
v = tr[v].next[s[i]];
}
len = min(len, (int)s.length ());
tr[v].leaf = true;
}
main () {
int n;
cin >> n;
init_trie();
len = inf;
for (int i = 0; i < n; ++i) {
string s;
cin >> s;
add_string (s);
cout << len << "\n";
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8bWFwPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNvbnN0IGludCBNQVhMRU4gPSAxMDAwOyAvLyDQvNCw0LrRgdC40LzQsNC70YzQvdCw0Y8g0LTQu9C40L3QsCDQstGB0LXRhSDRgdGC0YDQvtC6CmNvbnN0IGludCBpbmYgPSAxMDAwOwoKc3RydWN0IHZlcnRleCB7CiAgICBtYXAgPGNoYXIsIGludD4gbmV4dDsKICAgIGJvb2wgbGVhZjsKfTsKCmludCBzeiwgbGVuOwp2ZXJ0ZXggdHJbTUFYTEVOXTsKCnZvaWQgaW5pdF90cmllICgpIHsKICAgIHN6ID0gMDsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgTUFYTEVOOyArK2kpIHsKICAgICAgICB0cltpXS5uZXh0LmNsZWFyICgpOwogICAgICAgIHRyW2ldLmxlYWYgPSBmYWxzZTsKICAgIH0KICAgIHN6Kys7Cn0KCnZvaWQgYWRkX3N0cmluZyAoc3RyaW5nIHMpIHsKICAgIGludCB2ID0gMDsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgcy5sZW5ndGggKCk7ICsraSkgewogICAgICAgIGlmICghdHJbdl0ubmV4dC5jb3VudCAoc1tpXSkpIHsKICAgICAgICAgICAgdHJbdl0ubmV4dFtzW2ldXSA9IHN6Kys7CiAgICAgICAgfQogICAgICAgIGlmICh0clt2XS5uZXh0LnNpemUgKCkgPiAxKSB7CiAgICAgICAgICAgIGxlbiA9IG1pbihsZW4sIGkpOwogICAgICAgIH0KICAgICAgICB2ID0gdHJbdl0ubmV4dFtzW2ldXTsKICAgIH0KICAgIGxlbiA9IG1pbihsZW4sIChpbnQpcy5sZW5ndGggKCkpOwogICAgdHJbdl0ubGVhZiA9IHRydWU7Cn0KCm1haW4gKCkgewogICAgaW50IG47CiAgICBjaW4gPj4gbjsKICAgIGluaXRfdHJpZSgpOwogICAgbGVuID0gaW5mOwogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyArK2kpIHsKICAgICAgICBzdHJpbmcgczsKICAgICAgICBjaW4gPj4gczsKICAgICAgICBhZGRfc3RyaW5nIChzKTsKICAgICAgICBjb3V0IDw8IGxlbiA8PCAiXG4iOwogICAgfQp9Cg==