#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
int main() {
  map<string, int> subStrings;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string str;
    cin >> str;
    for (int f = 0; f < str.size(); f++) {
      for (int len = 1; len <= str.size() - f; len++) {
        string subStr = "";
        for (int j = 0; j < len; j++) {
          subStr += str[f + j];
        }
        if (subStrings.find(subStr) != subStrings.end() &&
            subStrings.find(subStr)->second != i) {
          subStrings[subStr] = -1;
        } else {
          subStrings.insert({subStr, i});
        }
      }
    }
  }
  vector<string> ans(n, "1000000000");
  for (auto it = subStrings.begin(); it != subStrings.end(); it++) {
    if (it->second != -1 &&
        ans[it->second - 1].length() > (it->first).length()) {
      ans[it->second - 1] = it->first;
    }
  }
  for (auto &i : ans) {
    cout << i << endl;
  }
  return 0;
}
