#include <bits/stdc++.h>
using namespace std;
string s[70010];
map<pair<int, int>, int> m;
pair<int, int> ans[70010];
int main() {
  int k = 64, p = 5;
  int n, i, j, l;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> s[i];
  for (i = 1; i <= n; i++)
    for (j = 0; j < 9; j++) {
      int x = 0;
      for (l = j; l < 9; l++) {
        x = x * 10 + s[i][l] - '0';
        if (m.find(pair<int, int>(x, l - j + 1)) != m.end() &&
            m[pair<int, int>(x, l - j + 1)] != i)
          m[pair<int, int>(x, l - j + 1)] = -1;
        else
          m[pair<int, int>(x, l - j + 1)] = i;
      }
    }
  for (auto it = m.begin(); it != m.end(); it++) {
    if (it->second == -1) continue;
    if (ans[it->second].second == 0 ||
        ans[it->second].second > it->first.second)
      ans[it->second] = pair<int, int>(it->first.first, it->first.second);
  }
  for (i = 1; i <= n; i++) {
    char s[10];
    sprintf(s, "%%0%dd\n", ans[i].second);
    printf(s, ans[i].first);
  }
  return 0;
}
