#include <bits/stdc++.h>
using namespace std;
void KeepTrying() {
  int n;
  cin >> n;
  map<string, int> mp;
  vector<string> V(n);
  for (auto& v : V) {
    cin >> v;
    unordered_set<string> seen;
    for (int i = 1; i <= 9; i++) {
      for (int j = 0; j <= 9 - i; j++) {
        string x = v.substr(j, i);
        if (!seen.count(x)) {
          mp[x]++;
          seen.insert(x);
        }
      }
    }
  }
  for (auto& v : V) {
    string ans;
    for (int i = 1; i <= 9; i++) {
      for (int j = 0; j <= 9 - i; j++) {
        string x = v.substr(j, i);
        if (mp[x] == 1) {
          ans = x;
          goto here;
        }
      }
    }
  here:
    cout << ans << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int DontGiveUp = 1;
  while (DontGiveUp--) KeepTrying();
  return 0;
}
