#include <bits/stdc++.h>
using namespace std;
map<string, long long> m;
vector<string> v;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    string s, x;
    set<string> se;
    cin >> s;
    v.push_back(s);
    for (long long i = 0; i < 9; i++) {
      x = "";
      for (long long j = i; j < 9; j++) {
        x.push_back(s[j]);
        if (se.find(x) == se.end()) {
          se.insert(x);
          m[x]++;
        }
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    string s = v[i], x, wy = "1111111111";
    for (long long i = 0; i < 9; i++) {
      x = "";
      for (long long j = i; j < 9; j++) {
        x.push_back(s[j]);
        if (x.size() >= wy.size()) break;
        if (m[x] == 1) wy = x;
      }
    }
    cout << wy << "\n";
  }
  return 0;
}
