#include <bits/stdc++.h>
using namespace std;
using LL = long long;
char s[70000][12];
LL calc(char *s, int n) {
  LL ans = n;
  for (int i = 0; i < n; i++) {
    ans = ans * 10 + s[i] - '0';
  }
  return ans;
}
int main() {
  int n;
  cin >> n;
  map<LL, int> mp;
  for (int i = 0; i < n; i++) {
    scanf("%s", s[i]);
    for (int j = 0; j < 9; j++)
      for (int k = j + 1; k <= 9; k++) mp[calc(s[i] + j, k - j)]++;
  }
  for (int i = 0; i < n; i++) {
    map<LL, int> tmp;
    for (int len = 1; len <= 9; len++) {
      for (int j = 0; j + len <= 9; j++) {
        tmp[calc(s[i] + j, len)]++;
      }
    }
    int find = false;
    for (int len = 1; !find && len <= 9; len++) {
      for (int j = 0; !find && j + len <= 9; j++) {
        if (tmp[calc(s[i] + j, len)] == mp[calc(s[i] + j, len)]) {
          find = true;
          s[i][j + len] = 0;
          printf("%s\n", s[i] + j);
        }
      }
    }
  }
  return 0;
}
