#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
using namespace std;
template <class T, class U>
inline void checkmin(T &x, U y) {
  if (y < x) x = y;
}
template <class T, class U>
inline void checkmax(T &x, U y) {
  if (y > x) x = y;
}
template <class T, class U>
inline bool ifmax(T &x, U y) {
  if (y > x) return x = y, true;
  return false;
}
template <class T, class U>
inline bool ifmin(T &x, U y) {
  if (y < x) return x = y, true;
  return false;
}
template <class T>
inline void sort(T &a) {
  sort(a.begin(), a.end());
}
template <class T>
inline void rsort(T &a) {
  sort(a.rbegin(), a.rend());
}
template <class T>
inline void reverse(T &a) {
  reverse(a.begin(), a.end());
}
template <class T, class U>
inline istream &operator>>(istream &str, pair<T, U> &p) {
  return str >> p.first >> p.second;
}
template <class T>
inline istream &operator>>(istream &str, vector<T> &a) {
  for (auto &i : a) str >> i;
  return str;
}
template <class T>
inline T sorted(T a) {
  sort(a);
  return a;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12);
  srand(94385);
  unordered_map<string, unordered_set<int>> st;
  int n;
  cin >> n;
  vector<string> a(n);
  cin >> a;
  for (int i = 0; i < n; ++i) {
    for (int l = 0; l < signed(a[i].size()); ++l)
      for (int r = l; r < signed(a[i].size()); ++r)
        st[a[i].substr(l, r - l + 1)].insert(i);
  }
  for (int i = 0; i < n; ++i) {
    pair<int, string> ans = {11, ""};
    for (int l = 0; l < signed(a[i].size()); ++l)
      for (int r = l; r < signed(a[i].size()); ++r) {
        string str = a[i].substr(l, r - l + 1);
        if (signed(st[str].size()) == 1)
          checkmin(ans, pair<int, string>(signed(str.size()), str));
      }
    cout << ans.second << '\n';
  }
  return 0;
}
