#include <bits/stdc++.h>
using namespace std;
long long const MAXN = 2e5 + 10;
long long n, m, T, a[MAXN];
string s[MAXN];
unordered_map<string, long long> mp;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    cin >> s[i];
    for (long long j = 0; j < s[i].size(); ++j) {
      string sub = "";
      for (long long k = j; k < s[i].size(); ++k) {
        sub += s[i][k];
        mp[sub]++;
      }
    }
  }
  for (long long i = 1; i <= n; ++i) {
    string res = "";
    for (long long j = 0; j < s[i].size(); ++j) {
      string sub = "";
      for (long long k = j; k < s[i].size(); ++k) {
        sub += s[i][k];
        mp[sub]--;
      }
    }
    long long Min = 1e9;
    for (long long j = 0; j < s[i].size(); ++j) {
      string sub = "";
      for (long long k = j; k < s[i].size(); ++k) {
        sub += s[i][k];
        if (mp[sub] == 0) {
          if (Min > sub.size()) Min = sub.size(), res = sub;
        }
      }
    }
    for (long long j = 0; j < s[i].size(); ++j) {
      string sub = "";
      for (long long k = j; k < s[i].size(); ++k) {
        sub += s[i][k];
        mp[sub]++;
      }
    }
    cout << res << endl;
  }
  return 0;
}
