#include <bits/stdc++.h>
using namespace std;
vector<int> h[100007];
int n, m, a[70005][50], t, s, ans[70005], d[70005 * 9], p[70005],
    cnt[70005 * 9], lst[70005 * 9];
void put_in(int x, int y) {
  t++;
  d[t] = x;
  cnt[t] = 1;
  lst[t] = y;
  h[x % 100007].push_back(t);
}
int find_(int x) {
  int tt = x % 100007;
  for (int i = 0; i < h[tt].size(); i++)
    if (d[h[tt][i]] == x) return h[tt][i];
  return 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &t);
    s = 0;
    for (int j = 1; j <= 9; j++) {
      a[i][++s] = t % 10;
      t /= 10;
    }
    for (int k = 2; k <= 9; k++)
      for (int j = 1; k + j <= 10; j++) {
        s++;
        a[i][s] = a[i][s - 10 + k] * 10 + a[i][j];
      }
  }
  s = 1;
  memset(ans, -1, sizeof(ans));
  for (int i = 1; i <= 9; i++) {
    t = 0;
    memset(cnt, 0, sizeof(cnt));
    memset(lst, 0, sizeof(lst));
    for (int j = 0; j < 100007; j++) h[j].clear();
    for (int j = 1; j <= n; j++)
      for (int k = s; k < s + 10 - i; k++) {
        int ss = find_(a[j][k]);
        if (!ss)
          put_in(a[j][k], j);
        else if (lst[ss] != j)
          cnt[ss]++, lst[ss] = j;
      }
    for (int j = 1; j <= n; j++)
      for (int k = s; k < s + 10 - i; k++) {
        if (ans[j] == -1 && cnt[find_(a[j][k])] == 1) {
          p[j] = i;
          ans[j] = a[j][k];
        }
      }
    s += (10 - i);
  }
  for (int i = 1; i <= n; i++) {
    t = ans[i];
    do {
      p[i]--;
      t /= 10;
    } while (t);
    for (int j = 0; j < p[i]; j++) printf("0");
    printf("%d\n", ans[i]);
  }
  return 0;
}
