#include <bits/stdc++.h>
using namespace std;
bool DEB = 0;
void __start__() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
mt19937_64 rnd(time(0));
using ll = long long;
using vi = vector<int>;
using ld = long double;
using pii = pair<int, int>;
void test_case() {
  int n;
  cin >> n;
  string s[n], t;
  map<string, unordered_set<int>> mp;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
    for (int j = 0; j < 9; ++j) {
      t = "";
      for (int k = j; k < 9; ++k) {
        t += s[i][k];
        mp[t].insert(i);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    int mnj = -100, mnk = 100;
    for (int j = 0; j < 9; ++j) {
      t = "";
      for (int k = j; k < 9; ++k) {
        t += s[i][k];
        if (((int)(mp[t].size())) == 1 && k - j < mnk - mnj) {
          mnk = k;
          mnj = j;
        }
      }
    }
    for (int j = mnj; j <= mnk; ++j) cout << s[i][j];
    cout << '\n';
  }
}
signed main() {
  __start__();
  int Q = 1;
  while (Q--) test_case();
}
