#include <bits/stdc++.h>
using namespace std;
map<string, int> M;
const int MAXN = 70100;
int n;
string A[MAXN];
string ans[MAXN];
void load() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) cin >> A[i];
}
void solve() {
  for (int i = 0; i < n; i++) ans[i] = "";
  for (int k = 1; k <= 9; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j + k - 1 < 9; j++) {
        string ss = A[i].substr(j, k);
        if (M[ss] == 0)
          M[ss] = i + 1;
        else if (M[ss] > 0 && M[ss] != i + 1)
          M[ss] = -1;
      }
    }
  }
  for (int k = 1; k <= 9; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j + k - 1 < 9; j++) {
        string ss = A[i].substr(j, k);
        if (ans[i] == "" && M[ss] == i + 1) ans[i] = ss;
      }
    }
  }
  for (int i = 0; i < n; i++) cout << ans[i] << endl;
}
int main() {
  load();
  solve();
  return 0;
}
