#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 3;
const int inf = 1e9 + 3;
const int md = 1e9 + 7;
const long long linf = 1e18 + 3;
int n, m;
map<string, int> kl;
map<string, bool> used;
string a[70001];
int main() {
  cin >> n;
  for (int v = 1; v <= n; ++v) {
    cin >> a[v];
    int ln = a[v].size();
    string num;
    used.clear();
    for (int i = 0; i < ln; ++i) {
      num = "";
      for (int j = i; j < ln; ++j) {
        num += (a[v][j]);
        if (!used[num]) {
          used[num] = true;
          kl[num]++;
        }
      }
    }
  }
  for (int v = 1; v <= n; ++v) {
    int ln = a[v].size();
    string num, res = "";
    int mn = 20;
    for (int i = 0; i < ln; ++i) {
      num = "";
      for (int j = i; j < ln; ++j) {
        num += (a[v][j]);
        if (kl[num] == 1) {
          if (j - i + 1 < mn) {
            mn = j - i + 1;
            res = num;
          }
        }
      }
    }
    cout << res << '\n';
  }
}
