#include <bits/stdc++.h>
using namespace std;
const int MaxN = 70003;
int n, a[MaxN];
int pw[10];
map<pair<int, int>, int> s;
inline int Get(const int& x, const int& l, const int& r) {
  return (x % pw[9 - l + 1]) / pw[9 - r];
}
inline void join(int x) {
  static pair<int, int> a[100];
  memset(a, 0, sizeof a);
  int cnt = 0;
  for (int i = 1; i <= 9; ++i)
    for (int j = i; j <= 9; ++j)
      a[++cnt] = pair<int, int>(j - i + 1, Get(x, i, j));
  sort(a + 1, a + cnt + 1);
  cnt = unique(a + 1, a + cnt + 1) - a - 1;
  for (int i = 1; i <= cnt; ++i) s[a[i]]++;
}
inline pair<int, int> query(int x) {
  for (int len = 1; len <= 9; ++len)
    for (int i = 1; i <= 9 - len + 1; ++i) {
      pair<int, int> t = pair<int, int>(len, Get(x, i, i + len - 1));
      if (s[t] == 1) return t;
    }
  return pair<int, int>(0, -1);
}
int main() {
  pw[0] = 1;
  for (int i = 1; i <= 9; ++i) pw[i] = pw[i - 1] * 10;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i), join(a[i]);
  for (int i = 1; i <= n; ++i) {
    pair<int, int> t = query(a[i]);
    int l = 0, x = t.second;
    while (x) x /= 10, l++;
    for (int j = l + 1; j <= t.first; ++j) putchar('0');
    if (t.second)
      printf("%d\n", t.second);
    else
      putchar('\n');
  }
  return 0;
}
