#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
bool debug = 0;
const int N = 9e5;
int prox[11][N];
int fim[N];
int main() {
  int n;
  scanf("%d", &n);
  vector<string> v(n);
  memset(fim, -1, sizeof(fim));
  int sz = 1;
  if (n != 3 and n != 4) {
    if (debug)
      cout << "n"
           << " = " << (n) << endl;
  }
  for (int ii = 0; ii < n; ii++) {
    cin >> v[ii];
    string s = v[ii];
    for (int i = 0; i < s.size(); i++) {
      int cur = 0;
      for (int j = i; j <= s.size() - 1; j++) {
        int c = s[j] - '0';
        if (!prox[c][cur]) {
          prox[c][cur] = sz++;
        }
        cur = prox[c][cur];
        fim[cur] = (fim[cur] == -1 or fim[cur] == ii) ? ii : INT_MAX;
      }
    }
  }
  if (n != 3 and n != 4) {
    if (debug)
      cout << "n"
           << " = " << (n) << endl;
  }
  for (int ii = 0; ii < n; ii++) {
    int len = 10;
    string s = v[ii];
    string sans;
    for (int i = 0; i < s.size(); i++) {
      int cur = 0;
      for (int j = i; j <= s.size() - 1; j++) {
        int c = s[j] - '0';
        cur = prox[c][cur];
        if (fim[cur] != INT_MAX) {
          if (j - i + 1 < len) {
            len = j - i + 1;
            sans = s.substr(i, len);
          }
        }
      }
    }
    printf("%s\n", sans.c_str());
  }
  return 0;
}
