#include <bits/stdc++.h>
using namespace std;
const int maxN = 71000;
const int maxL = 9;
set<int> T[maxN][maxL + 1];
map<int, int> T2[maxL + 1];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n, x, y, i, j, l, k;
  set<int>::iterator its;
  map<int, int>::iterator itm;
  string cad, ans;
  cin >> n;
  for (l = 0; l < n; l++) {
    cin >> cad;
    for (k = 1; k <= 9; k++) {
      for (j = k - 1; j < 9; j++) {
        x = 0;
        for (i = j + 1 - k; i <= j; i++) {
          x *= 10;
          x += cad[i] - '0';
        }
        T[l][k].insert(x);
        itm = T2[k].find(x);
        if (itm == T2[k].end())
          T2[k].insert(pair<int, int>(x, l));
        else if (itm->second != l)
          itm->second = -1;
      }
    }
  }
  for (l = 0; l < n; l++) {
    y = -1;
    for (k = 1; k <= 9; k++) {
      for (its = T[l][k].begin(); its != T[l][k].end(); its++) {
        x = *its;
        itm = T2[k].find(x);
        if (itm->second != -1) {
          y = itm->second;
          break;
        }
      }
      if (y != -1) break;
    }
    cad = "";
    ans = "";
    while (x > 0) {
      cad.push_back((x % 10) + '0');
      x /= 10;
    }
    reverse(cad.begin(), cad.end());
    for (i = cad.size(); i < k; i++) ans.push_back('0');
    for (i = 0; i < cad.size(); i++) ans.push_back(cad[i]);
    cout << ans << '\n';
  }
}
