#include <bits/stdc++.h>
using namespace std;
struct re {
  string s;
  int id;
  bool operator()(const re &a, const re &b) {
    if (a.s.size() < b.s.size()) return 1;
    if (a.s.size() > b.s.size()) return 0;
    return a.s < b.s || (a.s == b.s && a.id < b.id);
  }
} a[4000001];
int n, res, cnt;
bool vis[80001];
string Ans[80001];
char s[80001];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s + 1);
    for (int j = 1; j <= 9; ++j) {
      string tmp;
      for (int k = j; k <= 9; ++k) {
        tmp = tmp + s[k];
        a[++cnt] = (re){tmp, i};
      }
    }
  }
  sort(a + 1, a + 1 + cnt, re());
  for (int i = 1; i <= cnt; ++i) {
    int j;
    for (j = i; j + 1 <= cnt && a[j + 1].s == a[j].s; ++j)
      ;
    if (a[i].id == a[j].id && !vis[a[i].id]) {
      vis[a[i].id] = 1;
      Ans[a[i].id] = a[i].s;
    }
    i = j;
  }
  for (int i = 1; i <= n; ++i) printf("%s\n", Ans[i].c_str());
  return 0;
}
