#include <bits/stdc++.h>
using namespace std;
int n, mapCounter = 1, powers[2][9];
string num[70001];
set<pair<int, int> > s;
map<pair<int, int>, int> m;
int main() {
  long long int temp1 = 1, temp2 = 1;
  for (int i = 0; i < 9; ++i) {
    powers[0][i] = temp1;
    powers[1][i] = temp2;
    temp1 *= 69;
    temp1 %= 1000000007;
    temp2 *= 69;
    temp2 %= 961748941;
  }
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> num[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 9; ++j) {
      long long int cur1 = 0, cur2 = 0;
      for (int k = j; k < 9; ++k) {
        cur1 *= 69;
        cur1 %= 1000000007;
        cur1 += (num[i][k] - '0') + 1;
        cur2 *= 69;
        cur2 %= 961748941;
        cur2 += (num[i][k] - '0') + 1;
        s.insert(make_pair(cur1, cur2));
      }
    }
    for (set<pair<int, int> >::iterator i = s.begin(); i != s.end(); ++i) {
      if (m.find(*i) == m.end()) m.insert(make_pair(*i, 0));
      m[*i]++;
    }
    s.clear();
  }
  for (int i = 0; i < n; ++i) {
    int ansFound = 0;
    for (int j = 0; j < 9; ++j) {
      for (int k = 0; k + j < 9; ++k) {
        long long int cur1 = 0, cur2 = 0;
        for (int l = k; l <= k + j; ++l) {
          cur1 *= 69;
          cur1 %= 1000000007;
          cur1 += (num[i][l] - '0') + 1;
          cur1 %= 1000000007;
          cur2 *= 69;
          cur2 %= 961748941;
          cur2 += (num[i][l] - '0') + 1;
          cur2 %= 961748941;
        }
        if (m[make_pair(cur1, cur2)] == 1) {
          for (int l = k; l <= k + j; ++l) {
            cout << num[i][l];
          }
          cout << '\n';
          ansFound = 1;
          break;
        }
      }
      if (ansFound == 1) break;
    }
  }
}
