#include <bits/stdc++.h>
using namespace std;
int n;
struct value {
  int num, belong;
};
bool com(value a, value b) {
  if (a.num == b.num) return a.belong < b.belong;
  return a.num < b.num;
}
value temp[650000];
char str[70020][10];
int along[70020];
int valuee[70020];
int num[20];
int get(int len) {
  int tot = 0;
  temp[tot].num = 0;
  for (int i = 0; i < n; i++) {
    int s = -1, r = -1;
    while (r <= 8) {
      s++;
      r = s;
      while (r - s + 1 <= len) {
        temp[tot].num = temp[tot].num * 10 + (str[i][r] - '0');
        r++;
      }
      temp[tot].belong = i;
      tot++;
      temp[tot].num = 0;
    }
  }
  return tot;
}
bool check(int j) {
  if (j == 0) return temp[j].num != temp[j + 1].num;
  if (temp[j - 1].num != temp[j].num && temp[j].num != temp[j + 1].num)
    return true;
  else
    return false;
}
int main() {
  scanf("%d", &n);
  num[1] = 1;
  for (int i = 2; i <= 10; i++) num[i] = num[i - 1] * 10;
  for (int i = 0; i < n; i++) {
    scanf("%s", str[i]);
  }
  for (int i = 0; i < n; i++) along[i] = -1;
  for (int i = 1; i < 10; i++) {
    int all = get(i);
    sort(temp, temp + all, com);
    int tott = 0;
    int rr = 1;
    while (rr < all) {
      while (temp[rr].num == temp[tott].num &&
             temp[rr].belong == temp[tott].belong && rr < all)
        rr++;
      if (rr < all) temp[++tott] = temp[rr];
    }
    for (int j = 0; j <= tott; j++) {
      if (check(j) && along[temp[j].belong] == -1)
        along[temp[j].belong] = i, valuee[temp[j].belong] = temp[j].num;
    }
  }
  for (int i = 0; i < n; i++) {
    int r = along[i];
    while (num[r] > valuee[i]) {
      printf("0");
      r--;
    }
    if (valuee[i]) printf("%d", valuee[i]);
    printf("\n");
  }
  return 0;
}
