#include <bits/stdc++.h>
void Solve();
int main() { Solve(); }
using namespace std;
const long long INF = 1e9 + 1;
bool v(char x) {
  return (x == 'a' || x == 'u' || x == 'e' || x == 'i' || x == 'o');
}
map<string, set<long long> > m;
void Solve() {
  long long n;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (long long j = 0; j < s.size(); ++j) {
      for (long long k = j; k < s.size(); ++k) {
        m[s.substr(j, k - j + 1)].insert(i);
      }
    }
  }
  vector<string> res(n);
  for (auto p : m) {
    if (p.second.size() == 1) {
      long long idx = *p.second.begin();
      if (res[idx] == "" || p.first.size() < res[idx].size())
        res[idx] = p.first;
    }
  }
  for (long long i = 0; i < n; ++i) {
    cout << res[i] << '\n';
  }
}
