#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int i, j, k, n, m, len, index;
  map<string, long long int> mp;
  map<string, long long int> mpp;
  pair<string, long long int> p;
  map<string, long long int>::iterator it;
  cin >> n;
  string s[n + 1], st;
  string res[n + 1];
  for (i = 0; i < n; i++) {
    cin >> s[i];
    map<string, long long int> vis;
    for (j = 0; j < s[i].size(); j++) {
      for (len = 1; len <= s[i].size() - j; len++) {
        st = s[i].substr(j, len);
        if (vis[st] == 0) {
          mp[st]++;
          mpp[st] = i;
          vis[st] = 1;
        }
      }
    }
  }
  for (it = mp.begin(); it != mp.end(); it++) {
    if (it->second == 1) {
      index = mpp[it->first];
      if (res[index].size() > it->first.size() || res[index].size() == 0)
        res[index] = it->first;
    }
  }
  for (i = 0; i < n; i++) cout << res[i] << "\n";
}
