#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
string c[200009];
int n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    set<string> s;
    string tmp = c[i];
    for (int i = 0; i < tmp.size(); i++) {
      string in = "";
      for (int j = i; j < tmp.size(); j++) {
        in += tmp[j];
        s.insert(in);
      }
    }
    for (auto x : s) {
      mp[x]++;
    }
  }
  string ans = "";
  for (int i = 0; i < n; i++) {
    ans = "11111111111111111111111";
    string tmp = c[i];
    set<string> s;
    for (int i = 0; i < tmp.size(); i++) {
      string in = "";
      for (int j = i; j < tmp.size(); j++) {
        in += tmp[j];
        s.insert(in);
      }
    }
    for (auto x : s) {
      if (mp[x] == 1) {
        if (x.size() < ans.size()) {
          ans = x;
        }
      }
    }
    cout << ans << "\n";
  }
}
