#include <bits/stdc++.h>
using namespace std;
void _dbg(string) { cout << endl; }
template <class H, class... T>
void _dbg(string s, H h, T... t) {
  int l = s.find(',');
  cout << s.substr(0, l) << " = " << h << ", ";
  _dbg(s.substr(l + 1), t...);
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U> &p) {
  o << "(" << p.first << "," << p.second << ")";
  return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "[";
  for (T t : v) {
    o << t << ",";
  }
  o << "]";
  return o;
}
char str[70005][10];
struct node {
  node() {}
  int cnt;
  int last;
  node *nxt[10];
};
node *newnode() {
  node *v = new node();
  v->cnt = 0;
  v->last = -1;
  for (int i = (int)(0); i < (int)(10); i++) v->nxt[i] = nullptr;
  return v;
}
void add_node(node *v, int i, int j) {
  if (v->last < i) {
    v->last = i;
    v->cnt++;
  }
  if (j < 9) {
    int to = str[i][j] - '0';
    if (v->nxt[to] == nullptr) v->nxt[to] = newnode();
    add_node(v->nxt[to], i, j + 1);
  }
}
int sol(node *v, int i, int j) {
  if (v->cnt == 1) return 0;
  if (j == 9) return 1120000000;
  return sol(v->nxt[str[i][j] - '0'], i, j + 1) + 1;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = (int)(0); i < (int)(n); i++) scanf("%s", str[i]);
  if (n == 1) {
    cout << str[0][0] << endl;
    return 0;
  }
  node *root = newnode();
  for (int i = (int)(0); i < (int)(n); i++) {
    for (int j = (int)(0); j < (int)(9); j++) {
      add_node(root, i, j);
    }
  }
  for (int i = (int)(0); i < (int)(n); i++) {
    int a = 0, b = 9;
    for (int j = (int)(0); j < (int)(9); j++) {
      int r = sol(root, i, j);
      if (r < b) {
        a = j;
        b = r;
      }
    }
    for (int j = (int)(a); j < (int)(a + b); j++) printf("%c", str[i][j]);
    printf("\n");
  }
  return 0;
}
