#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
const int alp = 10;
int sz = 1;
struct node {
  int edge[alp];
  set<int> ls;
};
node trie[N];
void create_root() {
  for (int i = 0; i < alp; ++i) {
    trie[0].edge[i] = -1;
  }
  trie[0].ls = {};
}
void add_string(string s, int num) {
  int v = 0, n = s.length();
  ;
  for (int i = 0; i < n; ++i) {
    int c = s[i] - '0';
    if (trie[v].edge[c] == -1) {
      for (int j = 0; j < alp; ++j) {
        trie[sz].edge[j] = -1;
      }
      trie[sz].ls = {};
      trie[v].edge[c] = sz++;
    }
    v = trie[v].edge[c];
    trie[v].ls.insert(num);
  }
}
bool check(string s) {
  int v = 0, n = s.length();
  for (int i = 0; i < n; ++i) {
    int c = s[i] - '0';
    v = trie[v].edge[c];
  }
  return trie[v].ls.size() == 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  create_root();
  vector<string> arr(n), ans(n);
  for (int i = 0; i < n; ++i) {
    cin >> arr[i];
    ans[i] = arr[i];
    for (int j = arr[i].length() - 1; j >= 0; --j) {
      string s;
      for (int k = j; k < arr[i].length(); ++k) {
        s += arr[i][k];
      }
      add_string(s, i);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int b = 0; b < arr[i].length(); ++b) {
      string s;
      for (int j = b; j < arr[i].length(); ++j) {
        s += arr[i][j];
        if (check(s) && s.length() < ans[i].length()) {
          ans[i] = s;
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << "\n";
  }
  return 0;
}
