#include <bits/stdc++.h>
using namespace std;
int n, tot, a[100009], pw[19], fst[20000003], px[70001 * 9 * 9],
    py[70001 * 9 * 9], sz[70001 * 9 * 9], nxt[70001 * 9 * 9];
void ins(int x, int y, int w) {
  int z = (x + y * 2333) % 20000003, i;
  for (i = fst[z]; i; i = nxt[i])
    if (px[i] == x && py[i] == y) {
      if (sz[i] != w) sz[i] = -1;
      return;
    }
  px[++tot] = x;
  py[tot] = y;
  nxt[tot] = fst[z];
  fst[z] = tot;
  sz[tot] = w;
}
int calc(int x, int y) {
  int z = (x + y * 2333) % 20000003, i;
  for (i = fst[z]; i; i = nxt[i])
    if (px[i] == x && py[i] == y) return sz[i];
  return 0;
}
int main() {
  scanf("%d", &n);
  int i, j, k;
  for (i = pw[0] = 1; i <= 9; i++) pw[i] = pw[i - 1] * 10;
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    for (j = 1; j <= 9; j++)
      for (k = 0; k < j; k++) ins(a[i] % pw[j] / pw[k], j - k, i);
  }
  for (i = 1; i <= n; i++) {
    int ans = 10, x, y;
    for (j = 1; j <= 9; j++)
      for (k = 0; k < j; k++)
        if (calc(a[i] % pw[j] / pw[k], j - k) == i) {
          if (j - k < ans) {
            ans = j - k;
            x = j;
            y = k;
          }
        }
    a[i] %= pw[x];
    for (j = x - 1; j >= y; j--) printf("%d", a[i] / pw[j] % 10);
    puts("");
  }
  return 0;
}
