#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 70000;
const int LEN = 9;
int n;
int val[MAXN];
int p10[LEN + 1];
map<int, int> cnt[LEN + 1];
bool ok(int cur, int len) { return cnt[len][cur] == 1; }
void solve(int want) {
  for (int len = (1); len <= (9); ++len)
    for (int off = (0); off <= (LEN - len); ++off) {
      int cur = want / p10[off] % p10[len];
      if (ok(cur, len)) {
        printf("%0*d\n", len, cur);
        return;
      }
    }
  printf("err\n");
}
void run() {
  scanf("%d", &n);
  for (int i = (0); i < (n); ++i) scanf("%d", &val[i]);
  p10[0] = 1;
  for (int i = (1); i <= (LEN); ++i) p10[i] = p10[i - 1] * 10;
  for (int len = (1); len <= (9); ++len)
    for (int i = (0); i < (n); ++i) {
      set<int> cur;
      for (int off = (0); off <= (LEN - len); ++off) {
        cur.insert(val[i] / p10[off] % p10[len]);
      }
      for (auto it = cur.begin(); it != cur.end(); ++it) ++cnt[len][*it];
    }
  for (int i = (0); i < (n); ++i) solve(val[i]);
}
int main() {
  run();
  return 0;
}
