#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)1e5 + 10;
vector<string> data;
pair<int, int> getHash(string s) {
  int res = 0;
  for (int i = 0; i < s.size(); i++) {
    res *= 10;
    res += (int)(s[i] - '0');
  }
  return make_pair(s.size(), res);
}
string getString(int len, int val) {
  string s = to_string(val);
  reverse(s.begin(), s.end());
  int zeros = len - s.size();
  for (int i = 0; i < zeros; i++) {
    s += "0";
  }
  reverse(s.begin(), s.end());
  return s;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    data.push_back(s);
  }
  vector<pair<int, int> > answer(n);
  for (int i = 0; i < n; i++) {
    answer[i] = getHash(data[i]);
  }
  map<pair<int, int>, int> cntHashes;
  map<pair<int, int>, int> where;
  for (int idx = 0; idx < n; idx++) {
    string s = data[idx];
    set<pair<int, int> > hashes;
    for (int i = 0; i < s.size(); i++) {
      for (int j = i; j < s.size(); j++) {
        string sub = "";
        for (int k = i; k <= j; k++) {
          sub += s[k];
        }
        hashes.insert(getHash(sub));
      }
    }
    for (auto it : hashes) {
      cntHashes[it]++;
      where[it] = idx;
    }
  }
  for (auto it : cntHashes) {
    if (it.second == 1) {
      int idx = where[it.first];
      if (answer[idx] > it.first) {
        answer[idx] = it.first;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    string res = getString(answer[i].first, answer[i].second);
    cout << res << "\n";
  }
  return 0;
}
