#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, i, j, k, f, c;
  cin >> n;
  map<string, int> q;
  vector<string> s(n), ans(n);
  for (i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (j = 0; j < 10; j++) {
    q.clear();
    for (i = 0; i < n; i++) {
      for (c = 0; c + j < 10; c++) {
        string x = s[i].substr(c, j);
        if (q[x] == 0) {
          q[x] = i + 1;
        } else {
          if (q[x] != i + 1) {
            q[x] = -1;
          }
        }
      }
    }
    for (map<string, int>::iterator it = q.begin(); it != q.end(); it++) {
      if (it->second != -1 && ans[it->second - 1] == "") {
        ans[it->second - 1] = it->first;
      }
    }
  }
  for (i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
