#include <bits/stdc++.h>
using namespace std;
map<string, long long> mp;
void fill(vector<string> &ar) {
  long long n = ar.size();
  for (long long i = 0; i < n; i++) {
    set<string> st;
    for (long long j = 1; j <= 10; j++) {
      string s = ar[i].substr(0, j);
      st.insert(s);
      for (long long k = j; k < 9; k++) {
        s.erase(s.begin());
        s.push_back(ar[i][k]);
        st.insert(s);
      }
    }
    for (auto x : st) mp[x]++;
  }
}
pair<string, long long> check(long long len, string &str) {
  string x = str.substr(0, len);
  if (mp[x] == 1) {
    return {x, true};
  }
  for (long long k = len; k < 10; k++) {
    x.erase(x.begin());
    x.push_back(str[k]);
    if (mp[x] == 1) {
      return {x, 1};
    }
  }
  return {"", false};
}
void solve() {
  long long n;
  cin >> n;
  vector<string> ar(n);
  for (long long i = 0; i < n; i++) {
    cin >> ar[i];
  }
  fill(ar);
  for (long long i = 0; i < n; i++) {
    long long l = 1;
    long long r = 10;
    string res = ar[i];
    while (l <= r) {
      long long mid = (l + r) / 2;
      pair<string, bool> cur = check(mid, ar[i]);
      if (cur.second) {
        res = cur.first;
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    cout << res << '\n';
  }
}
int32_t main() { solve(); }
