#include <bits/stdc++.h>
using namespace std;
const int INF = 2147483647;
const int N = 70005;
map<int, int> mapa[10];
map<int, int>::iterator it;
set<int> ss[10];
set<int>::iterator it2;
int pot[9] = {9, 99, 999, 9999, 99999, 999999, 9999999, 99999999, 999999999};
char t[20];
int tab[N][10], i, j, num, k, n, r;
bool found;
void print(int l, int num) {
  string res = num == 0 ? "0" : "";
  while (num > 0) {
    res = char(num % 10 + 48) + res;
    num /= 10;
  }
  while (res.size() < l + 1) res = "0" + res;
  printf("%s\n", res.c_str());
}
int main() {
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", &t);
    for (j = 0; j < 9; j++) tab[i][j] = int(t[j]) - 48;
    for (j = 0; j < 9; j++) ss[j].clear();
    for (j = 0; j < 9; j++) {
      num = 0;
      for (k = j; k < 9; k++) {
        num = num * 10 + tab[i][k];
        ss[k - j].insert(num);
      }
    }
    for (j = 0; j < 9; j++) {
      for (it2 = ss[j].begin(); it2 != ss[j].end(); it2++) {
        it = mapa[j].find(*it2);
        if (it == mapa[j].end())
          r = 0;
        else
          r = it->second;
        mapa[j][*it2] = r + 1;
      }
    }
  }
  for (i = 0; i < n; i++) {
    found = false;
    for (j = 0; j < 9; j++) ss[j].clear();
    for (j = 0; j < 9; j++) {
      num = 0;
      for (k = j; k < 9; k++) {
        num = num * 10 + tab[i][k];
        ss[k - j].insert(num);
      }
    }
    for (j = 0; j < 9 && !found; j++) {
      for (it2 = ss[j].begin(); it2 != ss[j].end() && !found; it2++) {
        if (mapa[j].find(*it2)->second == 1) {
          print(j, *it2);
          found = true;
        }
      }
    }
  }
  return 0;
}
