#include <bits/stdc++.h>
using namespace std;
long long n;
string s[70005];
map<string, long long> mp;
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (long long(i) = (1); (i) <= (n); (i)++) cin >> s[i];
  for (long long(i) = (1); (i) <= (n); (i)++) {
    set<string> S;
    for (long long(j) = (0); (j) <= (9); (j)++)
      for (long long(k) = (0); (k) <= (9); (k)++) {
        if (j > k) continue;
        S.insert(s[i].substr(j, k - j + 1));
      }
    for (auto s : S) mp[s]++;
  }
  for (long long(i) = (1); (i) <= (n); (i)++) {
    for (long long(len) = (1); (len) <= (10); (len)++) {
      for (long long(l) = (0); (l) <= (9); (l)++) {
        if (l + len - 1 >= 10) continue;
        string t = s[i].substr(l, len);
        if (mp[t] == 1) {
          cout << t << endl;
          goto end;
        }
      }
    }
  end:;
  }
  return 0;
}
