#include <bits/stdc++.h>
using namespace std;
unordered_map<string, int> mymap;
string ans[70010];
int main() {
  int n, i, j, k;
  scanf("%d", &n);
  for (k = 0; k < n; k++) {
    string str;
    cin >> str;
    set<string> S;
    set<string>::iterator itset;
    for (i = 0; i < 9; i++) {
      string temp;
      for (j = i; j < 9; j++) {
        temp.push_back(str[j]);
        S.insert(temp);
      }
    }
    for (itset = S.begin(); itset != S.end(); itset++) {
      string temp = *itset;
      if (mymap.find(temp) == mymap.end())
        mymap.insert(make_pair(temp, k));
      else
        mymap[temp] = -1;
    }
  }
  for (i = 0; i < n; i++) ans[i] = "asfagsfgdgfag";
  unordered_map<string, int>::iterator it;
  for (it = mymap.begin(); it != mymap.end(); it++) {
    string curr = it->first;
    int cnt = it->second;
    if (cnt != -1) {
      if ((int)curr.size() < (int)ans[cnt].size()) ans[cnt] = curr;
    }
  }
  for (i = 0; i < n; i++) cout << ans[i] << endl;
  return 0;
}
