import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto N = readln.chomp.to!int;
    auto S = N.iota.map!(_ => readln.chomp).array;
    int[string] cnt;

    foreach (s; S) {
        bool[string] used;
        foreach (i; 0..9) {
            foreach (j; i..10) {
                if (s[i..j] in used)
                    continue;
                cnt[s[i..j]] += 1;
                used[s[i..j]] = true;
            }
        }
    }

    void solve(int ind) {
        foreach (len; 1..10)
            foreach (i; 0..10-len)
                if (cnt[S[ind][i..i+len]] == 1) {
                    writeln(S[ind][i..i+len]);
                    return;
                }
    }

    foreach (i; 0..N)
        solve(i);

}
