#include <bits/stdc++.h>
using namespace std;
const long long N = 500 * 1000 + 9;
const long long inf = 1e18;
const long long mod = 1e9 + 7;
void HakunaMatata() {
  long long n;
  cin >> n;
  map<string, long long> pp;
  string s[n];
  for (long long i = 0; i < n; i++) cin >> s[i];
  for (long long i = 0; i < n; i++) {
    map<string, long long> check;
    for (long long j = 0; j < (long long)s[i].size(); j++) {
      string a;
      for (long long k = j; k < (long long)s[i].size(); k++) {
        a.push_back(s[i][k]);
        if (check[a] == 0) {
          pp[a]++;
          check[a]++;
        }
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    long long mn = 10;
    string ans;
    for (long long j = 0; j < (long long)s[i].size(); j++) {
      string a;
      for (long long k = j; k < (long long)s[i].size(); k++) {
        a.push_back(s[i][k]);
        if (pp[a] == 1) {
          long long x = (long long)a.size();
          if (x < mn) {
            mn = x;
            ans = a;
          }
        }
      }
    }
    cout << ans << '\n';
  }
  return;
}
signed main() {
  HakunaMatata();
  return 0;
}
