#include <bits/stdc++.h>
using namespace std;
const int N = 70010;
char s[N][12];
int hsh[N][12];
int p[12];
map<int, int> mp[4];
int rec[7][1000010];
void print(int id, int l, int r) {
  int i;
  for (i = l; i <= r; i++) printf("%c", s[id][i]);
  printf("\n");
}
int main() {
  int i, j, k, l, r;
  int now;
  int n;
  int flag;
  p[0] = 1;
  for (i = 1; i <= 8; i++) p[i] = p[i - 1] * 10;
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%s", s[i] + 1);
    for (j = 1; j <= 9; j++) hsh[i][j] = hsh[i][j - 1] * 10 + s[i][j] - '0';
    for (k = 0; k <= 5; k++) {
      for (l = 1; l <= 9 - k; l++) {
        r = l + k;
        now = hsh[i][r] - hsh[i][l - 1] * p[r - l + 1];
        if (!rec[k][now])
          rec[k][now] = i;
        else if (rec[k][now] != i)
          rec[k][now] = -1;
      }
    }
    for (k = 6; k <= 8; k++) {
      for (l = 1; l <= 9 - k; l++) {
        r = l + k;
        for (j = l; j <= r; j++) {
          now = hsh[i][r] - hsh[i][l - 1] * p[r - l + 1];
          if (!mp[k - 6][now])
            mp[k - 6][now] = i;
          else if (mp[k - 6][now] != i)
            mp[k - 6][now] = -1;
        }
      }
    }
  }
  for (i = 1; i <= n; i++) {
    flag = 0;
    for (k = 0; k <= 5; k++) {
      for (l = 1; l <= 9 - k; l++) {
        r = l + k;
        now = hsh[i][r] - hsh[i][l - 1] * p[r - l + 1];
        if (rec[k][now] == i) {
          flag = 1;
          print(i, l, r);
          break;
        }
      }
      if (flag == 1) break;
    }
    if (flag == 1) continue;
    for (k = 6; k <= 8; k++) {
      for (l = 1; l <= 9 - k; l++) {
        r = l + k;
        now = hsh[i][r] - hsh[i][l - 1] * p[r - l + 1];
        if (mp[k - 6][now] == i) {
          flag = 1;
          print(i, l, r);
          break;
        }
      }
      if (flag == 1) break;
    }
  }
  return 0;
}
