#include <bits/stdc++.h>
using namespace std;
string str[70001];
unordered_map<string, int> sets;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n, flag;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> str[i];
  for (int i = 0; i < n; i++)
    for (int len = 1; len <= 9; len++)
      for (int j = 0; j <= 9 - len; j++) {
        if (sets.count(str[i].substr(j, len)) == 0)
          sets.insert({str[i].substr(j, len), i});
        else if (sets[str[i].substr(j, len)] != i)
          sets[str[i].substr(j, len)] = -1;
      }
  for (int i = 0; i < n; i++)
    for (int len = 1; len <= 9; len++) {
      for (int j = 0; j <= 9 - len; j++) {
        if (sets[str[i].substr(j, len)] != -1) {
          cout << str[i].substr(j, len) << "\n";
          flag = 1;
          break;
        }
      }
      if (flag == 1) {
        flag = 0;
        break;
      }
    }
}
