#include <bits/stdc++.h>
using namespace std;
struct trie {
  trie *ch[11];
  int r;
  trie() {
    memset(ch, NULL, sizeof ch);
    r = 0;
  }
  void add(char *s, int x) {
    if (*s == '\0') {
      r += x;
      return;
    }
    if (ch[*s - '0'] == NULL) ch[*s - '0'] = new trie();
    ch[*s - '0']->add(s + 1, x);
  }
  bool cal(char *s) {
    if (*s == '\0') {
      return r == 0;
    }
    if (ch[*s - '0'] == NULL) return 1;
    return ch[*s - '0']->cal(s + 1);
  }
};
char s[70005][11];
char s1[15];
char res[70005][11];
int z[70005];
int main() {
  int n;
  cin >> n;
  trie root;
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  int j1 = 0;
  for (int i = 0; i < n; i++) {
    z[i] = 10000;
    for (int j = 0; j < 9; j++) {
      j1 = 0;
      for (int k = j; k < 9; k++) {
        s1[j1++] = s[i][k];
        s1[j1] = '\0';
        root.add(s1, 1);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 9; j++) {
      j1 = 0;
      for (int k = j; k < 9; k++) {
        s1[j1++] = s[i][k];
        s1[j1] = '\0';
        root.add(s1, -1);
      }
    }
    for (int j = 0; j < 9; j++) {
      j1 = 0;
      for (int k = j; k < 9; k++) {
        s1[j1++] = s[i][k];
        s1[j1] = '\0';
        if (root.cal(s1)) {
          if (k - j + 1 < z[i]) {
            z[i] = k - j + 1;
            int k2 = 0;
            for (int k1 = j; k1 <= k; k1++) res[i][k2++] = s[i][k1];
            res[i][k2] = '\0';
          }
        }
      }
    }
    for (int j = 0; j < 9; j++) {
      j1 = 0;
      for (int k = j; k < 9; k++) {
        s1[j1++] = s[i][k];
        s1[j1] = '\0';
        root.add(s1, 1);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    puts(res[i]);
  }
  return 0;
}
