#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long INF = 1ll << 60;
const double Inf = 1e20;
const double eps = 1e-9;
void gmax(int &a, int b) { a = (a > b ? a : b); }
void gmin(int &a, int b) { a = (a < b ? a : b); }
const int maxn = 70005;
char str[maxn][10];
int n, MinLen, beg, ed;
map<unsigned long long, int> All, Current;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", str[i] + 1);
    unsigned long long tmp;
    Current.clear();
    for (int j = 1; j <= 9; ++j) {
      tmp = 0;
      for (int k = j; k <= 9; ++k) {
        tmp = tmp * 131 + str[i][k];
        if (!Current.count(tmp)) {
          Current[tmp] = 1;
          All[tmp]++;
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    unsigned long long tmp;
    MinLen = inf;
    for (int j = 1; j <= 9; ++j) {
      tmp = 0;
      for (int k = j; k <= 9; ++k) {
        tmp = tmp * 131 + str[i][k];
        if (All[tmp] == 1 && MinLen > k - j + 1) {
          MinLen = k - j + 1;
          beg = j;
          ed = k;
        }
      }
    }
    for (int j = beg; j <= ed; ++j) printf("%c", str[i][j]);
    printf("\n");
  }
  return 0;
}
