#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  string a[n + 1];
  for (int k = 1; k <= n; k++) {
    cin >> a[k];
    for (int i = 1; i <= 9; i++) {
      for (int j = 0; j <= 9 - i; j++) {
        string s1 = a[k].substr(j, i);
        if (mp[s1] == 0)
          mp[s1] = k;
        else {
          if (mp[s1] != k) mp[s1] = -1;
        }
      }
    }
  }
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= 9; i++) {
      long long ind1 = 0;
      for (int j = 0; j <= 9 - i; j++) {
        string s1 = a[k].substr(j, i);
        if (mp[s1] != -1) {
          cout << s1 << "\n";
          ind1 = 1;
          break;
        }
      }
      if (ind1 == 1) break;
    }
  }
  return 0;
}
