#include <bits/stdc++.h>
using namespace std;
const int NR = 1e5 + 100, oo = 1e9 + 10, MOD = 1e9 + 7;
const long double pi = 2 * acos(0.0);
int n;
map<string, int> mpp;
string dq;
string s;
vector<string> sol(NR);
int main() {
  int i, l, j;
  cin >> n;
  for (i = 1; i <= n; ++i) {
    cin >> s;
    for (j = 1; j <= 9; ++j) {
      for (l = 0; l + j <= 9; ++l) {
        dq = s.substr(l, j);
        if (mpp[dq] > 0 && mpp[dq] != i) {
          mpp[dq] = -1;
        }
        if (mpp[dq] == 0) {
          mpp[dq] = i;
        }
      }
    }
  }
  map<string, int>::iterator it;
  for (it = mpp.begin(); it != mpp.end(); ++it) {
    if ((*it).second == -1) continue;
    dq = (*it).first;
    if (sol[(*it).second].empty() ||
        (int)(dq.size()) < sol[(*it).second].size())
      sol[(*it).second] = dq;
  }
  for (i = 1; i <= n; ++i) cout << sol[i] << '\n';
  return 0;
}
