#include <bits/stdc++.h>
using namespace std;
const int MN = 70010;
vector<int> vs[MN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> vs(n);
  for (int i = 0; i < n; i++) cin >> vs[i];
  vector<string> ans(n);
  for (int len = 1; len < 10; len++) {
    map<string, set<int> > mapper;
    for (int i = 0; i < n; i++)
      for (int j = 0; j + len - 1 < 9; j++)
        mapper[vs[i].substr(j, len)].insert(i);
    for (auto &curr : mapper)
      if (((int)curr.second.size()) == 1) {
        int id = *curr.second.begin();
        if (ans[id] == "") ans[id] = curr.first;
      }
  }
  for (int i = 0; i < n; i++) cout << ans[i] << '\n';
  return 0;
}
