#include <bits/stdc++.h>
using namespace std;
long long int n, i, j, k;
string s, ss;
unordered_map<string, int> m;
unordered_set<string> st;
unordered_map<string, int>::iterator it;
int main() {
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s;
    for (j = 0; j < 9; j++) {
      for (k = 1; k <= 9 - j; k++) {
        ss = s.substr(j, k);
        if (m.empty() || (m.find(ss) == m.end() && st.find(ss) == st.end())) {
          m.insert({ss, i});
          continue;
        }
        if (m.find(ss) != m.end() && m.find(ss)->second != i) {
          st.insert(ss);
          m.erase(ss);
        }
      }
    }
  }
  vector<string> ans(n, "");
  for (it = m.begin(); it != m.end(); it++) {
    if (ans[it->second] == "" ||
        ans[it->second].length() > it->first.length()) {
      ans[it->second] = it->first;
    }
  }
  for (i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
