#include <bits/stdc++.h>
using namespace std;
string read_string() {
  static char buf[20];
  scanf("%s\n", buf);
  return buf;
}
int n;
vector<string> S;
bool read() {
  if (scanf("%d\n", &n) < 1) {
    return 0;
  }
  S.resize(n);
  for (int i = 0; i < int(n); ++i) {
    S[i] = read_string();
  }
  return 1;
}
int timer;
unordered_map<unsigned long long, int> when;
unordered_set<unsigned long long> bad;
unordered_set<unsigned long long> single;
int get_when(unsigned long long h) {
  auto it = when.find(h);
  if (it == when.end()) {
    return -1;
  }
  return it->second;
}
void update(unsigned long long h) {
  when[h] = timer;
  auto it = single.find(h);
  if (it != single.end()) {
    bad.insert(h);
  } else {
    single.insert(h);
  }
}
unsigned long long mrand() {
  unsigned long long x = rand();
  unsigned long long y = rand();
  return (x * RAND_MAX) ^ y;
}
unsigned long long coef[20];
void precalc() {
  for (int i = 0; i < int(20); ++i) {
    coef[i] = mrand();
  }
}
void solve() {
  when.clear();
  single.clear();
  bad.clear();
  timer = 0;
  for (const auto& s : S) {
    ++timer;
    for (int i = 0; i < int(((int)(s).size())); ++i) {
      unsigned long long h = 0;
      int len = 0;
      for (int j = i; j < ((int)(s).size()); ++j) {
        ++len;
        if (len == 9) {
          break;
        }
        h += coef[j - i] * (s[j] - '0' + 1);
        if (get_when(h) == timer) {
          continue;
        }
        update(h);
      }
    }
  }
  for (const auto& s : S) {
    string best = s;
    for (int i = 0; i < int(((int)(s).size())); ++i) {
      string cur;
      unsigned long long h = 0;
      int len = 0;
      for (int j = i; j < ((int)(s).size()); ++j) {
        ++len;
        if (len == 9) {
          break;
        }
        h += coef[j - i] * (s[j] - '0' + 1);
        cur += s[j];
        if (!bad.count(h)) {
          if (((int)(cur).size()) < ((int)(best).size())) {
            best = cur;
          }
        }
      }
    }
    printf("%s\n", best.data());
  }
}
int main() {
  precalc();
  while (read()) {
    solve();
  }
  return 0;
}
