#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > trie;
vector<int> cnt, last;
const int N = 7e4 + 20;
string in[N];
void insert(int idx, int st) {
  int cur = 0;
  cnt[cur] += last[cur] != idx;
  last[cur] = idx;
  for (int i = st; i < (int)in[idx].size(); i++) {
    if (trie[cur][in[idx][i] - '0'] == -1) {
      trie[cur][in[idx][i] - '0'] = trie.size();
      trie.push_back(vector<int>(10, -1));
      cnt.push_back(0);
      last.push_back(-1);
    }
    cur = trie[cur][in[idx][i] - '0'];
    cnt[cur] += last[cur] != idx;
    last[cur] = idx;
  }
}
void mn(int idx) {
  int mn = 10;
  string ans;
  for (int i = 0; i < (int)in[idx].size(); i++) {
    int cur = 0;
    for (int j = i; j < (int)in[idx].size(); j++) {
      if (trie[cur][in[idx][j] - '0'] == -1) {
        cout << cur << ' ' << i << ' ' << j << ' ' << idx << endl;
        cout << "BUG\n";
        return;
      }
      cur = trie[cur][in[idx][j] - '0'];
      if (cnt[cur] < 2) {
        if (cnt[cur] == 1 && mn > j - i + 1)
          mn = j - i + 1, ans = in[idx].substr(i, j - i + 1);
        break;
      }
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  trie.push_back(vector<int>(10, -1));
  cnt.push_back(0);
  last.push_back(-1);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> in[i];
    for (int j = 0; j < (int)in[i].size(); j++) insert(i, j);
  }
  for (int i = 0; i < n; i++) {
    mn(i);
  }
  return 0;
}
