#include <bits/stdc++.h>
int MX = 1000000007;
long long mod = MX;
long long MMX = (long long)MX * MX;
long long MMN = (long long)(-MX) * MX;
using namespace std;
int n;
string tels[70007];
long long hs[10];
map<long long, int> cntall;
map<long long, int> cnt[70007];
long long p = 1031;
long long st[10];
int main() {
  st[0] = 1;
  for (int i = 1; i <= 9; i++) st[i] = st[i - 1] * p;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> tels[i];
    hs[1] = tels[i][0];
    for (int o = 2; o <= 9; o++) {
      hs[o] = (hs[o - 1]) + tels[i][o - 1] * st[o - 1];
    }
    for (int o = 1; o <= 9; o++)
      for (int j = o; j <= 9; j++) {
        long long cs = (hs[j] - hs[o - 1]) * st[9 - o];
        cntall[cs]++;
        cnt[i][cs]++;
      }
  }
  for (int i = 1; i <= n; i++) {
    hs[1] = tels[i][0];
    for (int o = 2; o <= 9; o++) {
      hs[o] = (hs[o - 1]) + tels[i][o - 1] * st[o - 1];
    }
    int fnd = 2;
    for (int j = 1; j <= 9; j++)
      for (int o = 1; o <= 9; o++)
        if (o + j - 1 <= 9 && fnd) {
          long long cs = (hs[o + j - 1] - hs[o - 1]) * st[9 - o];
          if (cntall[cs] == cnt[i][cs]) {
            for (int r = o; r <= o + j - 1; r++) cout << tels[i][r - 1];
            cout << endl;
            fnd = 0;
          }
        }
  }
  return 0;
}
