#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<string> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  map<string, int> mp;
  vector<string> ans(n);
  for (int i = 0; i < ans.size(); i++) ans[i] = "999999999999";
  for (int i = 0; i < n; i++) {
    for (int l = 0; l < v[i].size(); l++) {
      string vr = "";
      for (int r = l; r < v[i].size(); r++) {
        vr.push_back(v[i][r]);
        if (mp.find(vr) != mp.end() && mp[vr] != i)
          mp[vr] = -1;
        else
          mp[vr] = i;
      }
    }
  }
  for (auto now : mp) {
    if (now.second != -1) {
      if (ans[now.second].size() > now.first.size())
        ans[now.second] = now.first;
    }
  }
  for (int i = 0; i < ans.size(); i++) cout << ans[i] << ' ';
  return 0;
}
