#include <bits/stdc++.h>
using namespace std;
int n, i, j, vis[71111], a[1111111], nf[1111111], ans[71111], alen[71111];
char s[71111][11];
map<int, int> ma, maz;
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%s", s[i]);
  int mo = 1;
  for (i = 1; i <= 6; i++) {
    memset(nf, 0, sizeof(nf));
    mo *= 10;
    for (j = 1; j <= n; j++) {
      int t = 0;
      for (int k = 0; k < i; k++) t = t * 10 + s[j][k] - '0';
      if (!nf[t]) {
        a[t] = j;
        nf[t] = 1;
      } else
        nf[t] = 2;
      for (int k = i; k < 9; k++) {
        t = (t % (mo / 10)) * 10 + s[j][k] - '0';
        if (!nf[t] || j == a[t]) {
          a[t] = j;
          nf[t] = 1;
        } else
          nf[t] = 2;
      }
    }
    for (j = 0; j < mo; j++)
      if (nf[j] == 1 && alen[a[j]] == 0) {
        ans[a[j]] = j;
        alen[a[j]] = i;
      }
  }
  for (i = 7; i <= 9; i++) {
    for (j = 1; j <= n; j++) {
      for (int k = 0; k < 10 - i; k++) {
        int t = 0;
        for (int l = 0; l < i; l++) t = t * 10 + s[j][k + l] - '0';
        ma[t]++;
        if (ma[t] == 2 && maz[t] == j) ma[t]--;
        maz[t] = j;
      }
    }
    map<int, int>::iterator it;
    for (it = ma.begin(); it != ma.end(); it++) {
      if (it->second == 1 && alen[maz[it->first]] == 0) {
        ans[maz[it->first]] = it->first;
        alen[maz[it->first]] = i;
      }
    }
    ma.clear();
    maz.clear();
  }
  for (i = 1; i <= n; i++) {
    mo = 0;
    int t = ans[i];
    while (t / 10) {
      mo++;
      t /= 10;
    }
    for (j = 1; j < alen[i] - mo; j++) printf("0");
    printf("%d", ans[i]);
    printf("\n");
  }
}
