#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long MOD = 1e9 + 7;
inline long long add(long long &x, long long y) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
inline long long sub(long long x, long long y) {
  x -= y;
  if (x < 0) x += mod;
  return x;
}
inline long long mul(long long x, long long y) { return (x * 1ll * y) % mod; }
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline void io() {}
map<string, long long> mp;
signed main() {
  io();
  long long n;
  cin >> n;
  vector<string> v(n);
  for (long long i = 0; i < n; i++) {
    string s;
    cin >> s;
    v[i] = s;
    set<string> st;
    for (long long i = 1; i <= 9; i++) {
      for (long long j = 0; j < 9 - i + 1; j++) {
        string t = s.substr(j, i);
        if (st.count(t) == 0) {
          mp[t]++;
          st.insert(t);
        }
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    bool f = true;
    string s = v[i];
    for (long long i = 1; i <= 9; i++) {
      for (long long j = 0; j < 9 - i + 1; j++) {
        string t = s.substr(j, i);
        if (mp[t] == 1) {
          cout << t << endl;
          f = false;
          break;
        }
      }
      if (!f) break;
    }
  }
}
