#include <bits/stdc++.h>
using namespace std;
int ch[3000000][10], c[100];
bool ok[3000000];
int s[3000000];
char a[10], b[70010][10];
int main() {
  int n, m = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%s", a + 1);
    int l = 0;
    for (int p = 1; p <= 9; p++) {
      int k = 0;
      for (int j = p; j <= 9; j++) {
        int first = a[j] - 48;
        if (!ch[k][first]) ch[k][first] = ++m;
        k = ch[k][first];
        if (!ok[k]) {
          ok[k] = 1;
          c[++l] = k;
          s[k]++;
        }
      }
    }
    for (int j = 1; j <= 9; j++) b[i][j] = a[j];
    for (int j = 1; j <= l; j++) ok[c[j]] = 0;
  }
  for (int i = 1; i <= n; i++) {
    int ans = 10, first = 1, second = 9;
    for (int p = 1; p <= 9; p++) {
      int k = 0;
      for (int j = p; j <= 9; j++) {
        k = ch[k][b[i][j] - 48];
        if (s[k] == 1) {
          if (j - p + 1 < ans) {
            ans = min(ans, j - p + 1);
            first = p;
            second = j;
          }
          break;
        }
      }
    }
    for (int p = first; p <= second; p++) putchar(b[i][p]);
    puts("");
  }
  return 0;
}
