#include <bits/stdc++.h>
using namespace std;
string s;
int n;
unordered_map<string, int> tree;
vector<string> a;
unordered_map<string, int>::iterator it;
int main() {
  cin >> n;
  a.resize(n);
  for (int z = 0; z < n; z++) {
    a[z] = "1234567890";
  }
  for (int z = 0; z < n; z++) {
    cin >> s;
    for (int i = 0; i < 9; i++) {
      for (int j = 1; j <= 9 - i; j++) {
        tree[s.substr(i, j)];
        if (tree[s.substr(i, j)] == 0)
          tree[s.substr(i, j)] = z + 1;
        else if (tree[s.substr(i, j)] != z + 1)
          tree[s.substr(i, j)] = -1;
      }
    }
  }
  for (it = tree.begin(); it != tree.end(); it++) {
    if ((*it).second != -1) {
      if ((*it).first.length() < a[(*it).second - 1].length())
        a[(*it).second - 1] = (*it).first;
    }
  }
  for (int z = 0; z < a.size(); z++) {
    cout << a[z] << endl;
  }
  return 0;
}
