#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  unordered_map<string, vector<int>> id;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int x = 0; x < (int)s.length(); x++) {
      for (int y = x; y < (int)s.length(); y++) {
        id[s.substr(x, y - x + 1)].push_back(i);
      }
    }
  }
  vector<string> res(n);
  for (auto s : id) {
    sort(s.second.begin(), s.second.end());
    if (s.second.front() == s.second.back()) {
      string c = s.first;
      int i = s.second[0];
      if (!res[i].length() || c.length() < res[i].length()) res[i] = c;
    }
  }
  for (int i = 0; i < n; i++) cout << res[i] << endl;
  return 0;
}
