#include <bits/stdc++.h>
int main() {
  int n;
  std::cin >> n;
  std::map<std::string, int> dict;
  std::vector<std::string> ans(n);
  for (int i = 0; i < n; ++i) {
    std::string s;
    std::cin >> s;
    ans[i] = s;
    for (size_t j = 0; j < s.length(); ++j) {
      for (size_t l = 1; l <= s.length(); ++l) {
        if (j + l <= s.length()) {
          if (dict.find(s.substr(j, l)) == dict.end()) {
            dict[s.substr(j, l)] = i;
          } else {
            if (dict[s.substr(j, l)] != i) {
              dict[s.substr(j, l)] = -1;
            }
          }
        }
      }
    }
  }
  for (std::map<std::string, int>::iterator it = dict.begin(); it != dict.end();
       ++it) {
    if (it->second != -1 && ans[it->second].length() > (it->first).length()) {
      ans[it->second] = it->first;
    }
  }
  for (int i = 0; i < n; ++i) {
    std::cout << ans[i] << std::endl;
  }
}
