#include <bits/stdc++.h>
using namespace std;
inline bool is_palindrome(const string& s) {
  return std::equal(s.begin(), s.end(), s.rbegin());
}
const long long MOD = 1000000007;
const long long INF = 1e9 + 5;
const double eps = 1e-7;
const double PI = acos(-1.0);
inline void debug_vi(vector<int> a) {
  for (long long i = (long long)(0); i < (long long)(a.size()); i++)
    cout << a[i] << " ";
}
inline void debug_vll(vector<long long> a) {
  for (long long i = (long long)(0); i < (long long)(a.size()); i++)
    cout << a[i] << " ";
}
int trie[3000000][10];
int nxt = 1;
void insert(string s) {
  int node = 0;
  for (int i = 0; i < s.size(); i++) {
    if (trie[node][s[i] - '0'] == 0) {
      node = trie[node][s[i] - '0'] = nxt;
      nxt++;
    } else {
      node = trie[node][s[i] - '0'];
    }
  }
}
int find(string s) {
  int idx = 0;
  for (int i = 0; i < s.size(); i++)
    if (trie[idx][s[i] - '0'] == 0)
      return 0;
    else
      idx = trie[idx][s[i] - '0'];
  return 1;
}
string ans[3000000];
map<string, int> m;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, sz;
  cin >> n;
  string s;
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    ans[i] = "abc";
    cin >> s;
    sz = s.size();
    for (long long j = (long long)(0); j < (long long)(sz); j++) {
      for (long long k = (long long)(j); k < (long long)(sz); k++) {
        string tmp = s.substr(j, k - j + 1);
        if (!find(tmp)) {
          m[tmp] = i;
        } else {
          m[tmp] = -1;
        }
      }
    }
    reverse(s.begin(), s.end());
    string tmp = "";
    for (long long j = (long long)(0); j < (long long)(sz); j++) {
      tmp.push_back(s[j]);
      reverse(tmp.begin(), tmp.end());
      insert(tmp);
      reverse(tmp.begin(), tmp.end());
    }
  }
  for (auto itr : m) {
    if (itr.second == -1) continue;
    if (ans[itr.second] == "abc" || ans[itr.second].size() > itr.first.size())
      ans[itr.second] = itr.first;
  }
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    cout << ans[i] << "\n";
  }
  return 0;
}
