#include <bits/stdc++.h>
using namespace std;
vector<string> vs;
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin >> n;
  map<string, int> kek;
  for (int i = 0; i < n; ++i) {
    string t;
    cin >> t;
    map<string, int> cura;
    for (int j1 = 1; j1 <= 9; ++j1)
      for (int j = 0; j < 10 - j1; ++j) {
        if (!cura[t.substr(j, j1)]) kek[t.substr(j, j1)]++;
        cura[t.substr(j, j1)]++;
      }
    vs.push_back(t);
  }
  for (auto t : vs) {
    for (int j1 = 1; j1 <= 9; ++j1)
      for (int j = 0; j < 10 - j1; ++j) {
        if (kek[t.substr(j, j1)] == 1) {
          cout << t.substr(j, j1) << endl;
          goto keka;
        }
      }
  keka:;
  }
  return 0;
}
