#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int N = 70005;
string s[N];
string ans[N];
map<string, int> mp;
int cnt[2000000];
inline int func(string s) {
  if ((int)(s.size()) <= 6) {
    s = "1" + s;
    int ret = 0;
    for (int i = 0; i < (int)(s.size()); i++) {
      ret = ret * 10 + (s[i] - '0');
    }
    return cnt[ret];
  } else
    return mp[s];
}
inline void insert(string s, int ind) {
  if ((int)(s.size()) <= 6) {
    s = "1" + s;
    int ret = 0;
    for (int i = 0; i < (int)(s.size()); i++) {
      ret = ret * 10 + (s[i] - '0');
    }
    if (cnt[ret] == ind || cnt[ret] == 0)
      cnt[ret] = ind;
    else
      cnt[ret] = 700000;
  } else {
    int tmp = mp[s];
    if (tmp == 0 || tmp == ind)
      mp[s] = ind;
    else
      mp[s] = 700000;
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    for (int j = 0; j < 9; j++) {
      string tmp = "";
      for (int k = j; k < 9; k++) {
        tmp += s[i][k];
        insert(tmp, i);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    ans[i] = s[i];
    for (int j = 0; j < 9; j++) {
      string tmp = "";
      for (int k = j; k < 9; k++) {
        tmp += s[i][k];
        if (func(tmp) == i) {
          if ((int)(tmp.size()) < (int)(ans[i].size())) {
            ans[i] = tmp;
          }
        }
      }
    }
    cout << ans[i] << "\n";
  }
  return 0;
}
