#include <bits/stdc++.h>
using namespace std;
long long readi() {
  long long input = 0;
  char c = ' ';
  while (c < '-') {
    c = getchar();
  }
  bool negative = false;
  if (c == '-') {
    negative = true;
    c = getchar();
  }
  while (c >= '0') {
    input = 10 * input + (c - '0');
    c = getchar();
  }
  if (negative) {
    input = -input;
  }
  return input;
}
void printi(long long output) {
  if (output == 0) {
    putchar('0');
    return;
  }
  if (output < 0) {
    putchar('-');
    output = -output;
  }
  int aout[20];
  int ilen = 0;
  while (output) {
    aout[ilen] = ((output % 10));
    output /= 10;
    ilen++;
  }
  for (int i = ilen - 1; i >= 0; i--) {
    putchar(aout[i] + '0');
  }
  return;
}
string reads() {
  string input = "";
  char c = ' ';
  while (c <= ' ') {
    c = getchar();
  }
  while (c > ' ') {
    input += c;
    c = getchar();
  }
  return input;
}
void prints(string output) {
  for (int i = 0; i < output.length(); i++) {
    putchar(output[i]);
  }
  return;
}
long long getrand() {
  long long rand1 = (rand() % 536870912);
  long long rand2 = (rand() % 536870912);
  return (rand1 * 536870912ll + rand2);
}
int N;
string arr[100010];
set<pair<long long, long long> > s;
map<pair<long long, long long>, int> mp;
int ans[100010], lt[100010], rt[100010];
pair<long long, long long> hashval;
int32_t main() {
  srand(time(NULL));
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  ios_base::sync_with_stdio(false);
  if (fopen("cf860b.in", "r")) {
    freopen("cf860b.in", "r", stdin);
  }
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < arr[i].length(); j++) {
      hashval = make_pair(0, 0);
      for (int k = j; k < arr[i].length(); k++) {
        hashval.first *= 1000861;
        hashval.first += arr[i][k];
        hashval.first %= 1000000007;
        hashval.second *= 1000861;
        hashval.second += arr[i][k];
        hashval.second %= 1000000861;
        s.insert(hashval);
      }
    }
    for (auto it = s.begin(); it != s.end(); it++) {
      mp[*it]++;
    }
    s.clear();
  }
  for (int i = 0; i < N; i++) {
    ans[i] = 1000000861;
    for (int j = 0; j < arr[i].length(); j++) {
      hashval = make_pair(0, 0);
      for (int k = j; k < arr[i].length(); k++) {
        hashval.first *= 1000861;
        hashval.first += arr[i][k];
        hashval.first %= 1000000007;
        hashval.second *= 1000861;
        hashval.second += arr[i][k];
        hashval.second %= 1000000861;
        if (mp[hashval] == 1 && (k - j + 1) < ans[i]) {
          ans[i] = k - j + 1;
          lt[i] = j;
          rt[i] = k;
        }
      }
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = lt[i]; j <= rt[i]; j++) {
      cout << arr[i][j];
    }
    cout << '\n';
  }
  return 0;
}
