#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
int n;
char s[100];
string ss, t;
string ans[70005];
int main() {
  scanf("%d ", &n);
  for (int i = 0; i < n; i++) {
    gets(s);
    ss = s;
    for (int j = 0; j < 9; j++) {
      for (int k = 1; j + k < 10; k++) {
        t = ss.substr(j, k);
        if (!mp.count(t))
          mp[t] = i << 1;
        else {
          if ((mp[t] >> 1) != i) mp[t] |= 1;
        }
      }
    }
    ans[i] = "1234567890";
  }
  for (map<string, int>::iterator it = mp.begin(); it != mp.end(); it++) {
    if ((it->second) & 1) continue;
    int x = (it->second) >> 1;
    if (ans[x].size() > (it->first).size()) ans[x] = (it->first);
  }
  for (int i = 0; i < n; i++) printf("%s\n", ans[i].c_str());
}
