#include <bits/stdc++.h>
using namespace std;
char s[70005][12];
int sz;
long long b[70005][12][12], a[70005 * 100];
int f(int &i, int x, int &y) {
  int ret = 0;
  while (x <= y) {
    ret = ret * 10 + (s[i][x] - '0');
    x++;
  }
  return ret;
}
int main() {
  int cases, caseno = 0, n, i, j, k, cnt, p, t, low, high, mid;
  long long x;
  bool flag;
  scanf("%d", &n);
  sz = 0;
  for (i = 1; i <= n; i++) {
    scanf("%s", s[i]);
    for (j = 1; j <= 9; j++) {
      for (k = 0; k <= 9 - j; k++) {
        p = k + j - 1;
        x = j;
        x = x * 100000000000LL;
        a[sz] = x + f(i, k, p);
        b[i][j][k] = a[sz];
        sz++;
      }
    }
  }
  sort(a, a + sz);
  for (i = 1; i <= n; i++) {
    flag = false;
    for (j = 1; j <= 9; j++) {
      for (k = 0; k <= 9 - j; k++) {
        low = 0, high = sz - 1, p = -1;
        x = b[i][j][k];
        while (low <= high) {
          mid = (low + high) >> 1;
          if (a[mid] == x) {
            p = mid;
            break;
          } else if (a[mid] < x)
            low = mid + 1;
          else
            high = mid - 1;
        }
        cnt = 1;
        t = p;
        while (t > 0 && a[t - 1] == x && cnt < 11) {
          t--;
          cnt++;
        }
        t = p;
        while (t < sz && a[t + 1] == x && cnt < 11) {
          t++;
          cnt++;
        }
        for (p = 0; p <= 9 - j; p++) {
          if (b[i][j][p] == x) cnt--;
        }
        if (cnt <= 0) {
          for (p = k; p <= k + j - 1; p++) printf("%c", s[i][p]);
          printf("\n");
          flag = true;
          break;
        }
      }
      if (flag) break;
    }
  }
  return 0;
}
