#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-8;
const int mod = 1e9 + 7;
const int N = 1e6 + 10;
const long long INF = 1e18;
long long power(long long x, long long y) {
  long long t = 1;
  while (y > 0) {
    if (y % 2)
      y -= 1, t = t * x % mod;
    else
      y /= 2, x = x * x % mod;
  }
  return t;
}
char s[100000][13], t[100000][13];
int ans[N];
map<int, int> M;
string convert(int z, int sz) {
  string s;
  while (sz) {
    s.push_back(z % 10 + '0');
    z /= 10;
    sz--;
  }
  reverse(s.begin(), s.end());
  return s;
}
int main() {
  int n;
  scanf("%d", &n);
  memset(ans, -1, sizeof(ans));
  for (int i = 0; i < n; ++i) scanf("%s", s[i]);
  for (int sz = 1; sz < 10; ++sz) {
    int ds = 1;
    for (int i = 0; i < sz; ++i) ds = ds * 10;
    for (int i = 0; i < n; ++i) {
      int cur = 0;
      for (int j = 0; j < 10 - sz; ++j) {
        if (j == 0) {
          for (int k = 0; k < sz; ++k) cur = cur * 10 + s[i][k] - '0';
        } else {
          cur = cur * 10 - (s[i][j - 1] - '0') * ds + s[i][j + sz - 1] - '0';
        }
        if (M.count(cur) && M[cur] != (i + 1)) {
          M[cur] = -1;
        } else {
          M[cur] = i + 1;
        }
      }
    }
    for (typeof(M.begin()) it = M.begin(); it != M.end(); it++) {
      int g = it->second - 1;
      if (it->second != -1 && ans[g] == -1) {
        ans[g] = 1;
        string p = convert(it->first, sz);
        for (int i = 0; i < p.size(); ++i) t[g][i] = p[i];
        t[g][sz] = '\0';
      }
    }
    M.clear();
  }
  for (int i = 0; i < n; ++i) printf("%s\n", t[i]);
  return 0;
}
