#include <bits/stdc++.h>
using namespace std;
int const N = 70001;
string a[N];
unordered_map<string, int> cnt;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    for (int j = 0; j < a[i].size(); ++j) {
      string tmp = "";
      for (int k = j; k < a[i].size(); ++k) {
        tmp += a[i][k];
        cnt[tmp]++;
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < a[i].size(); ++j) {
      string tmp = "";
      for (int k = j; k < a[i].size(); ++k) {
        tmp += a[i][k];
        cnt[tmp]--;
      }
    }
    string ans = "4930409324024903";
    for (int j = 0; j < a[i].size(); ++j) {
      string tmp = "";
      for (int k = j; k < a[i].size(); ++k) {
        tmp += a[i][k];
        if (cnt[tmp] == 0 && tmp.size() < ans.size()) {
          ans = tmp;
        }
      }
    }
    for (int j = 0; j < a[i].size(); ++j) {
      string tmp = "";
      for (int k = j; k < a[i].size(); ++k) {
        tmp += a[i][k];
        cnt[tmp]++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
