#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n;
  cin >> n;
  vector<string> v;
  for (long long i = 0; i < n; i++) {
    string temp;
    cin >> temp;
    v.push_back(temp);
  }
  map<string, long long> freq;
  for (long long i = 1; i <= 9; i++) {
    for (long long j = 0; j < n; j++) {
      for (long long k = 0; k < 9 - i + 1; k++) {
        string temp = v[j].substr(k, i);
        freq[temp]++;
      }
    }
  }
  for (long long j = 0; j < n; j++) {
    for (long long i = 1; i <= 9; i++) {
      for (long long k = 0; k < 9 - i + 1; k++) {
        string temp = v[j].substr(k, i);
        freq[temp]--;
      }
    }
    string res = "99999999999";
    for (long long i = 0; i < v[j].length(); i++) {
      long long l = i;
      long long r = v[j].length() - 1;
      while (l <= r) {
        if (l == r) {
          long long m = l;
          string temp = v[j].substr(i, m - i + 1);
          if (freq.find(temp) == freq.end() or freq[temp] == 0) {
            if (temp.length() < res.length()) {
              res = temp;
            }
          }
          break;
        }
        long long m = (l + r) / 2;
        string temp = v[j].substr(i, m - i + 1);
        if (freq.find(temp) == freq.end() or freq[temp] == 0) {
          r = m - 1;
          if (temp.length() < res.length()) {
            res = temp;
          }
        } else {
          l = m + 1;
        }
      }
    }
    for (long long i = 1; i <= 9; i++) {
      for (long long k = 0; k < 9 - i + 1; k++) {
        string temp = v[j].substr(k, i);
        freq[temp]++;
      }
    }
    cout << res << '\n';
  }
  return 0;
}
