#include <bits/stdc++.h>
using namespace std;
struct node {
  map<char, node *> m;
  int term = 0;
  set<int> sum;
  node() {}
  int add(const string &s, int ind = 0, int index = 0) {
    if (ind == s.size()) {
      ++term;
      sum.insert(index);
      return 0;
    }
    if (!m[s[ind]]) {
      m[s[ind]] = new node();
    }
    m[s[ind]]->add(s, ind + 1, index);
    sum.insert(index);
    return 0;
  }
  int get(const string &s, int ind) {
    if (sum.size() == 1) {
      return ind;
    }
    if (ind == s.size()) {
      return 10000;
    }
    return m[s[ind]]->get(s, ind + 1);
  }
};
int main() {
  int n;
  cin >> n;
  node *Tree = new node();
  vector<string> A(n);
  for (int i = 0; i < n; ++i) {
    cin >> A[i];
    for (int j = 0; j < A[i].size(); ++j) {
      Tree->add(A[i], j, i);
    }
  }
  if (n == 1) {
    cout << A[0][0] << endl;
    return 0;
  }
  for (int i = 0; i < n; ++i) {
    int minlen = 9, start = 0;
    for (int j = 0; j < A[i].size(); ++j) {
      int ans = Tree->get(A[i], j);
      if (ans - j < minlen) {
        start = j;
        minlen = ans - j;
      }
    }
    for (int j = 0; j < minlen; ++j) {
      cout << A[i][start + j];
    }
    cout << endl;
  }
  return 0;
}
