#include <bits/stdc++.h>
using namespace std;
char str[10001];
map<string, bool> G;
map<string, int> M;
int tot = 0;
string p[81 * 70002];
int deg[81 * 70002], l[81 * 70002];
vector<int> v[80001];
int n;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", str + 1);
    G.clear();
    for (int j = 1; j <= 9; j++) {
      string s = "";
      for (int k = j; k <= 9; k++) {
        s += str[k];
        if (!M.count(s)) {
          M[s] = ++tot;
          p[tot] = s;
          l[tot] = k - j + 1;
        }
        int x = M[s];
        if (deg[x] > 1) continue;
        if (!G.count(s)) {
          ++deg[x];
          G[s] = true;
          v[i].push_back(x);
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    int mn = 0x3f3f3f3f;
    int ans;
    for (int j = 0; j < (int)v[i].size(); j++) {
      int x = v[i][j];
      if (deg[x] > 1) continue;
      if (l[x] < mn) mn = l[x], ans = x;
    }
    int k = mn;
    for (int j = 0; j < k; j++) putchar(p[ans][j]);
    puts("");
  }
  return 0;
}
