#include <bits/stdc++.h>
using namespace std;
struct trie {
  int cnt, vis;
  trie *a[10];
  trie() {
    cnt = 0;
    vis = 0;
    for (int i = 0; i < 10; i++) a[i] = 0;
  }
};
void insert(trie *node, int pos, string s) {
  if (node->vis == 0) node->cnt++;
  node->vis = 1;
  if (pos == s.size()) return;
  int num = s[pos] - '0';
  if (node->a[num] == 0) node->a[num] = new trie;
  insert(node->a[num], pos + 1, s);
}
void rer(trie *node, int pos, string s) {
  node->vis = 0;
  if (pos == s.size()) return;
  int num = s[pos] - '0';
  if (node->a[num] == 0) node->a[num] = new trie;
  rer(node->a[num], pos + 1, s);
}
int query(trie *node, int pos, string s) {
  if (pos == s.size()) return node->cnt;
  int num = s[pos] - '0';
  return query(node->a[num], pos + 1, s);
}
trie *root = new trie;
int n;
string c[100009];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    string tmp = c[i];
    for (int i = 0; i < tmp.size(); i++) {
      string in = "";
      for (int j = i; j < tmp.size(); j++) {
        in += tmp[j];
        insert(root, 0, in);
      }
    }
    for (int i = 0; i < tmp.size(); i++) {
      string in = "";
      for (int j = i; j < tmp.size(); j++) {
        in += tmp[j];
        rer(root, 0, in);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    string tmp = c[i];
    string ans = "(((((((((((((((";
    for (int i = 0; i < tmp.size(); i++) {
      string in = "";
      for (int j = i; j < tmp.size(); j++) {
        in += tmp[j];
        if (query(root, 0, in) == 1 && in.size() < ans.size()) ans = in;
      }
    }
    cout << ans << "\n";
  }
}
