#include <bits/stdc++.h>
using namespace std;
long long powmod(long long a, long long b, long long MOD) {
  long long res = 1;
  a %= MOD;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
  }
  return res;
}
const int maxn = 7e4 + 10;
int n;
vector<string> vstr;
unordered_set<string> ms;
unordered_map<string, int> smp;
void process(const string& s) {
  for (int step = 1; step < 10; ++step)
    for (int st = 0; st < 9; ++st) {
      if (st + step <= 9 && smp[s.substr(st, step)] == 1) {
        cout << s.substr(st, step) << endl;
        return;
      }
    }
}
int main(int argc, char** argv) {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    ms.clear();
    for (int i = 0; i < 9; ++i)
      for (int j = i + 1; j < 10; ++j) {
        ms.emplace(s.substr(i, j - i));
      }
    for (const string& s : ms) {
      ++smp[s];
    }
    vstr.push_back(s);
  }
  for (int i = 0; i < n; ++i) {
    process(vstr.at(i));
  }
  return 0;
}
