#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  map<string, long long> ma;
  vector<string> v;
  for (long long i = 1; i <= n; i++) {
    string s;
    cin >> s;
    v.push_back(s);
    map<string, long long> m;
    for (long long j = 0; j < 9; j++) {
      string st;
      for (long long k = j; k < 9; k++) {
        st.push_back(s[k]);
        if (m[st] == 0) {
          ma[st]++;
        }
        m[st] = 1;
      }
    }
  }
  for (long long i = 0; i < v.size(); i++) {
    string s = v[i];
    string ans;
    long long minn = 1e12;
    for (long long j = 0; j < 9; j++) {
      string st;
      for (long long k = j; k < 9; k++) {
        st.push_back(s[k]);
        if (ma[st] == 1) {
          if (minn > st.size()) {
            minn = st.size();
            ans = st;
          }
        }
      }
    }
    cout << ans << endl;
  }
}
signed main() {
  long long t;
  ios_base::sync_with_stdio(false);
  t = 1;
  while (t--) solve();
  return 0;
}
