#include <bits/stdc++.h>
using namespace std;
unordered_map<string, set<long long>> mp;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vector<string> v;
  for (long long i = 0; i < n; i++) {
    string s;
    cin >> s;
    v.push_back(s);
    for (long long j = 0; j < 9; j++) {
      string x;
      for (long long k = j; k < 9; k++) {
        x += s[k];
        mp[x].insert(i);
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    string s = v[i];
    long long mn = 9;
    string ans = s;
    for (long long j = 0; j < 9; j++) {
      string x;
      for (long long k = j; k < 9; k++) {
        x += s[k];
        if (mp[x].size() == 1) {
          if (k - j + 1 < mn) {
            mn = k - j + 1;
            ans = x;
          }
        }
      }
    }
    cout << ans << '\n';
  }
}
