#include <bits/stdc++.h>
using namespace std;
long long fastpow(int a, int b, int MOD) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y) % MOD;
    }
    y = (y * y) % MOD;
    b /= 2;
  }
  return x;
}
long long InverseEuler(int n, int MOD) { return fastpow(n, MOD - 2, MOD); }
long long f[3];
bool init;
long long C(int n, int r, int MOD) {
  if (!init) {
    init = 1;
    f[0] = 1;
    for (int i = 1; i < 300000; i++) f[i] = (f[i - 1] * i) % MOD;
  }
  return (f[n] *
          ((InverseEuler(f[r], MOD) * InverseEuler(f[n - r], MOD)) % MOD)) %
         MOD;
}
int N;
string s[77000];
unordered_map<int, int> ct[9];
unordered_map<int, int> loc[9][77000];
int main() {
  std::ios::sync_with_stdio(false);
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> s[i];
    int M = s[i].length();
    for (int j = 0; j < M; j++) {
      int tmp = 0;
      for (int k = j; k < M; k++) {
        tmp = tmp * 10 + (s[i][k] - '0');
        ct[k - j][tmp]++;
        loc[k - j][i][tmp]++;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    int M = s[i].length();
    int ln = 10;
    int res;
    for (int j = 0; j < M; j++) {
      int tmp = 0;
      for (int k = j; k < M; k++) {
        if (k - j >= ln) break;
        tmp = tmp * 10 + (s[i][k] - '0');
        if (ct[k - j][tmp] == loc[k - j][i][tmp]) {
          res = tmp;
          ln = k - j;
        }
      }
    }
    string res2 = "";
    while (res) {
      res2 += '0' + (res % 10);
      res /= 10;
    }
    reverse(res2.begin(), res2.end());
    while (res2.size() != ln + 1) res2 = "0" + res2;
    cout << res2 << endl;
  }
}
