#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 10;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 10;
const int LOG = 20;
const long long BINF = 1e18 + 10;
const long long LINF = LLONG_MAX;
const long double EPS = 1e-9;
const long double PI = acos(-1);
inline void error() {
  cout << -1;
  exit(0);
}
int st[11], n;
vector<string> s(MAXN);
unordered_map<long long, int> mp, last;
inline int get(int n) {
  if (!n) {
    return 1;
  }
  for (int i = 9; i >= 0; i--) {
    if (n / st[i]) {
      return i + 1;
    }
  }
  return 0;
}
inline void source() {
  st[0] = 1;
  for (register int i(1); i <= 9; i++) {
    st[i] = st[i - 1] * 10;
  }
  cin >> n;
  for (register int k(1); k <= n; k++) {
    cin >> s[k];
    for (int i = 1; i <= 9; i++) {
      int now = 0;
      for (int j = 0; j <= i - 1; j++) {
        now = now * 10 + s[k][j] - '0';
      }
      mp[i * 1e15 + now]++;
      last[i * 1e15 + now] = k;
      for (int j = i; j < 9; j++) {
        now = (now % st[i - 1]) * 10 + s[k][j] - '0';
        if (last[i * 1e15 + now] != k) {
          last[i * 1e15 + now] = k;
          mp[i * 1e15 + now]++;
        }
      }
    }
  }
  for (register int k(1); k <= n; k++) {
    bool t = false;
    for (int i = 1; i <= 9; i++) {
      if (t) {
        break;
      }
      int now = 0;
      for (int j = 0; j <= i - 1; j++) {
        now = now * 10 + s[k][j] - '0';
      }
      if (mp[i * 1e15 + now] == 1) {
        for (register int j(1); j <= i - get(now); j++) {
          cout << 0;
        }
        cout << now << "\n";
        t = true;
        break;
      }
      for (int j = i; j < 9; j++) {
        if (t) {
          break;
        }
        now = (now % st[i - 1]) * 10 + s[k][j] - '0';
        if (mp[i * 1e15 + now] == 1) {
          for (register int j2(1); j2 <= i - get(now); j2++) {
            cout << 0;
          }
          cout << now << "\n";
          t = true;
          break;
        }
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  source();
  return 0;
}
