#include <bits/stdc++.h>
const int kN = 70000 + 5;
const int kD = kN * 45 + 100;
char s[kN][10];
int tot = 1, root = 1;
int node[kD][10], cnt[kD];
void modify(char *s, int slot) {
  for (int i = 0; i < 9; ++i) {
    for (int u = root, j = i; j < 9; ++j) {
      int c = s[j] - '0';
      if (node[u][c] == 0) node[u][c] = ++tot;
      u = node[u][c];
      cnt[u] += slot;
    }
  }
}
void query(char *s) {
  int bl = 0, br = 8;
  for (int i = 0; i < 9; ++i) {
    for (int u = root, j = i; j < 9; ++j) {
      u = node[u][s[j] - '0'];
      if (cnt[u] == 0) {
        if (br - bl + 1 > j - i + 1) {
          bl = i;
          br = j;
        }
        break;
      }
    }
  }
  for (int i = bl; i <= br; ++i) putchar(s[i]);
  puts("");
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
    modify(s[i], 1);
  }
  for (int i = 0; i < n; ++i) {
    modify(s[i], -1);
    query(s[i]);
    modify(s[i], 1);
  }
}
