#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, j, k, l, m, n;
  cin >> n;
  string s[n], t;
  for (i = 0; i < n; i++) {
    cin >> s[i];
  }
  map<string, vector<long long int>> mp;
  set<string> ss;
  for (i = 1; i <= 9; i++) {
    for (j = 0; j < n; j++) {
      for (k = 0; k + i - 1 < 9; k++) {
        t = s[j].substr(k, i);
        ss.insert(t);
      }
      while (ss.empty() != true) {
        mp[*(ss.begin())].push_back(j);
        ss.erase(ss.begin());
      }
    }
  }
  map<string, vector<long long int>>::iterator it;
  string fir;
  map<long long int, long long int> mpp;
  string ans[n];
  for (it = mp.begin(); it != mp.end(); it++) {
    fir = it->first;
    if (mp[fir].size() == 1 && mpp[mp[fir][0]] == 0) {
      mpp[mp[fir][0]] = 1;
      ans[mp[fir][0]] = fir;
    } else if (mp[fir].size() == 1 && mpp[mp[fir][0]] == 1) {
      if (fir.length() < ans[mp[fir][0]].length()) {
        ans[mp[fir][0]] = fir;
      }
    }
  }
  for (i = 0; i < n; i++) {
    cout << ans[i] << endl;
    ;
  }
}
