#include <bits/stdc++.h>
const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const long long MXLL = 9223372036854775807;
const int Sz = 1e5 + 1;
using namespace std;
inline void Read_rap() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
inline void randomizer3000() {
  unsigned int seed;
  asm("rdtsc" : "=A"(seed));
  srand(seed);
}
unordered_map<string, int> t[10];
int n;
string s[Sz];
string ans[Sz];
inline void add(string &s, int pos) {
  for (int i = 0; i < (int)(s.size()); i++) {
    string ss = "";
    for (int j = i; j < (int)(s.size()); j++) {
      ss.push_back(s[j]);
      int &x = t[j - i + 1][ss];
      if (!x)
        x = pos;
      else if (x != pos)
        x = -1;
    }
  }
}
int main() {
  Read_rap();
  for (int i = 1; i < 10; i++) {
    t[i].reserve(1024);
    t[i].max_load_factor(0.25);
  }
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    add(s[i], i);
  }
  for (int i = 1; i <= 9; i++) {
    for (auto x : t[i]) {
      if (x.second != -1 && !(int)(ans[x.second].size()))
        ans[x.second] = x.first;
    }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << endl;
  return 0;
}
