#include <bits/stdc++.h>
using namespace std;
unordered_map<string, int> cnt;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<string> store;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    int m = s.size();
    map<string, bool> done;
    for (int j = 0; j < m; ++j) {
      for (int len = 1; len <= m - j; ++len) {
        string curr = s.substr(j, len);
        if (done[curr] == 0) {
          cnt[s.substr(j, len)] += 1;
          done[curr] = 1;
        }
      }
    }
    store.push_back(s);
  }
  for (int i = 0; i < n; ++i) {
    string poss = "1243567891011";
    bool found = false;
    string chek = store[i];
    int m = chek.size();
    for (int j = 0; j < m; ++j) {
      for (int len = 1; len <= m - j; ++len) {
        string curr = chek.substr(j, len);
        if (cnt[curr] == 1) {
          if (poss.size() > curr.size()) {
            poss = curr;
          }
        }
      }
    }
    cout << poss << endl;
  }
  return 0;
  return 0;
}
