#include <bits/stdc++.h>
using namespace std;
const int N = 70000 + 100;
unordered_map<string, int> mp, cnt[N];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < 9; j++) {
      string sp = "";
      for (int k = j; k < 9; k++) {
        sp += s[k];
        mp[sp]++;
        cnt[i][sp]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    string s = "99999999999999";
    for (auto x : cnt[i]) {
      string sp = x.first;
      int val = x.second;
      if (mp[sp] == val && sp.size() < s.size()) {
        s = sp;
      }
    }
    cout << s << endl;
  }
}
