#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll N = 1e5;
map<pair<ll, ll>, ll> cnt;
ll n;
string arr[N];
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (ll t = 0; t < n; ++t) {
    string &s = arr[t];
    cin >> s;
    assert(s.size() == 9);
    for (ll i = 0; i < 9; ++i) {
      ll h = 0;
      for (ll j = i; j < 9; ++j) {
        h = 10 * h + s[j] - '0';
        ++cnt[make_pair(h, j - i + 1)];
      }
    }
  }
  for (ll t = 0; t < n; ++t) {
    string &s = arr[t];
    for (ll i = 0; i < 9; ++i) {
      ll h = 0;
      for (ll j = i; j < 9; ++j) {
        h = 10 * h + s[j] - '0';
        --cnt[make_pair(h, j - i + 1)];
      }
    }
    string ans = s;
    for (ll i = 0; i < 9; ++i) {
      ll h = 0;
      for (ll j = i; j < 9; ++j) {
        h = 10 * h + s[j] - '0';
        if (!cnt[make_pair(h, j - i + 1)]) {
          if ((ll)ans.size() > j - i + 1) {
            ans = s.substr(i, j - i + 1);
          }
        }
      }
    }
    for (ll i = 0; i < 9; ++i) {
      ll h = 0;
      for (ll j = i; j < 9; ++j) {
        h = 10 * h + s[j] - '0';
        ++cnt[make_pair(h, j - i + 1)];
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
