#include <bits/stdc++.h>
using namespace std;
int N;
int min_size = 10;
string numbers[70001], ans, sub;
unordered_map<string, int> freq, tmp;
unordered_map<string, int>::iterator itr;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> numbers[i];
    for (int j = 0; j <= 9; ++j) {
      for (int k = 1; k <= 9 - j; ++k) {
        sub = numbers[i].substr(j, k);
        tmp[sub]++;
      }
    }
    for (auto key : tmp) freq[key.first]++;
    tmp.clear();
  }
  for (int i = 0; i < N; ++i) {
    min_size = 10;
    for (int j = 0; j <= 9; ++j) {
      for (int k = 1; k <= 9 - j; ++k) {
        sub = numbers[i].substr(j, k);
        itr = freq.find(sub);
        if ((itr->second == 1) && (k < min_size)) {
          ans = sub;
          min_size = k;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
