#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> v(n);
  unordered_map<string, int> m;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    string s = v[i];
    unordered_set<string> second;
    for (int k = 0; k < 9; k++) {
      string pre = "";
      for (int j = k; j < 9; j++) {
        pre += s[j];
        if (!second.count(pre)) {
          m[pre]++;
          second.insert(pre);
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    int l = 1, r = 9, ans = 9;
    string s = v[i], res = v[i];
    while (l <= r) {
      int mid = (l + r) / 2, found = 0;
      for (int j = 0; j + mid - 1 < 9 && !found; j++) {
        string pre = s.substr(j, mid);
        if (m[pre] <= 1) res = pre;
      }
      if (res.size() == mid) {
        ans = mid;
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    cout << res << endl;
  }
  return 0;
}
