#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long INF = 1e18;
const int N = 7e4 + 5;
int n;
string s[N];
struct trie {
  struct trie* node[10];
  bool isend;
  int cnt;
};
struct trie* getnode() {
  struct trie* temp = new struct trie;
  for (int i = 0; i < 10; i++) {
    temp->node[i] = NULL;
  }
  temp->isend = 0;
  temp->cnt = 0;
  return temp;
}
struct trie* head = getnode();
void insert(string s) {
  struct trie* temp = head;
  for (auto x : s) {
    if (temp->node[x - '0']) {
      temp = temp->node[x - '0'];
      temp->cnt++;
      continue;
    }
    temp->node[x - '0'] = getnode();
    temp = temp->node[x - '0'];
    temp->cnt++;
  }
  temp->isend = 1;
}
int search(int idx, int off) {
  int i = off;
  struct trie* temp = head;
  while ((i < s[idx].size()) && (temp->node[s[idx][i] - '0']) &&
         ((temp->node[s[idx][i] - '0']->cnt) > 0)) {
    temp = temp->node[s[idx][i] - '0'];
    i++;
  }
  if (i == s[idx].size()) return -1;
  return i + 1;
}
void erase(string s) {
  struct trie* temp = head;
  for (auto x : s) {
    temp = temp->node[x - '0'];
    temp->cnt--;
  }
  temp->isend = 0;
}
bool ispresent(string s) {
  struct trie* temp = head;
  for (auto x : s) {
    if (!(temp->node[x - '0']) || temp->node[x - '0']->cnt < 0) return 0;
    temp = temp->node[x - '0'];
  }
  return (temp && temp->isend);
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < s[i].size(); j++) {
      insert(s[i].substr(j, s[i].size() - j));
    }
  }
  for (int i = 0; i < n; i++) {
    int mn = inf, p;
    for (int j = 0; j < s[i].size(); j++) {
      erase(s[i].substr(j, s[i].size() - j));
    }
    for (int j = 0; j < s[i].size(); j++) {
      int got = search(i, j);
      if (got != -1) {
        int res = got - j;
        if (res < mn) {
          mn = res;
          p = j;
        }
      }
    }
    for (int j = 0; j < s[i].size(); j++) {
      insert(s[i].substr(j, s[i].size() - j));
    }
    cout << s[i].substr(p, mn) << "\n";
  }
  return 0;
}
