#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
;
long long max(long long a, long long b) {
  if (a > b)
    return a;
  else
    return b;
}
long long min(long long a, long long b) {
  if (a > b)
    return b;
  else
    return a;
}
long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long normalize(long long x, long long mod) {
  x %= mod;
  if (x < 0) x += mod;
  return x;
}
long long dx[4] = {0, 0, 1, -1};
long long dy[4] = {1, -1, 0, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
const double PI = acosl(-1);
const long long mod = 1000 * 1000 * 1000 + 7;
const long long inf = 1e18 + 5;
inline long long add(long long a, long long b, long long p = mod) {
  long long c = a + b;
  if (c >= p) c -= p;
  return c;
}
inline long long sub(long long a, long long b, long long p = mod) {
  long long c = a - b;
  if (c < 0) c += p;
  return c;
}
inline long long mul(long long a, long long b, long long p = mod) {
  return (a * 1ll * b) % p;
}
long long floor1(long long n, long long k) {
  if (n % k == 0 || n >= 0) return n / k;
  return (n / k) - 1;
}
long long ceil1(long long n, long long k) { return floor1(n + k - 1, k); }
long long powm(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = (res * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
const long long N = 7e4 + 5;
long long n, a, b;
string s[N];
typedef struct data {
  data *bit[10];
  long long cnt = 0;
  long long flag = 0;
  long long level = 0;
  set<long long> st;
} trie;
trie *head;
void insert(long long pos, long long ind) {
  trie *cur = head;
  cur->level = 0;
  long long lev = 1;
  for (long long i = pos; i < 9; ++i) {
    long long b = s[ind][i] - '0';
    if (cur->bit[b] == NULL) {
      cur->bit[b] = new trie();
    }
    cur = cur->bit[b];
    cur->cnt++;
    cur->level = lev++;
    cur->st.insert(ind);
  }
  cur->flag = 1;
}
long long dfs(long long pos, long long ind) {
  trie *cur = head;
  long long len = 0;
  for (long long i = pos; i < 9; ++i) {
    long long b = s[ind][i] - '0';
    if (cur->st.size() == 1) {
      return len;
    }
    if (cur->bit[b] == NULL) {
      cout << ind << " " << i << " " << b << "\n";
      return 0;
    }
    cur = cur->bit[b];
    ++len;
  }
  if (cur->st.size() == 1) return len;
  return inf;
}
void solve() {
  head = new trie();
  cin >> n;
  for (long long i = (0); i < (n); ++i) {
    cin >> s[i];
    for (long long j = (0); j < (9); ++j) {
      insert(j, i);
    }
  }
  for (long long i = (0); i < (n); ++i) {
    long long mn = inf, pos = -1;
    for (long long j = (0); j < (9); ++j) {
      long long len = dfs(j, i);
      if (len < mn) {
        mn = len;
        pos = j;
      }
    }
    for (long long j = (pos); j < (pos + mn); ++j) cout << s[i][j];
    cout << "\n";
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
