#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d\n", &n);
  unordered_map<string, int> f1, f2;
  string str[100000];
  char tmp[30];
  for (int i = 1; i <= n; ++i) {
    scanf("%s", tmp);
    if (i < n) getchar();
    str[i] = tmp;
    str[i] = '0' + str[i];
    string t;
    for (int j = 1; j <= 9; ++j) {
      t.clear();
      for (int k = j; k <= 9; ++k) {
        t += str[i][k];
        if (f1[t] == 0) f1[t] = i;
        f2[t] = i;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    int length = 100;
    string ans;
    for (int j = 1; j <= 9; ++j) {
      string t;
      t.reserve(12);
      for (int k = j; k <= 9; ++k) {
        if (k - j + 1 > length) break;
        t += str[i][k];
        if (f1[t] == f2[t] && length > k - j + 1) {
          length = k - j + 1;
          ans = t;
        }
      }
    }
    printf("%s\n", ans.c_str());
  }
}
