#include <bits/stdc++.h>
const int mx = 1e6 + 5;
const int inf = 0x3f3f3f3f;
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  vector<string> v(n);
  vector<vector<string>> subs(n);
  unordered_map<string, int> mp;
  unordered_map<string, int> aux;
  for (int i = 0; i < n; ++i) cin >> v[i];
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= 9; ++j) {
      for (int k = 0; k + j - 1 < 9; ++k) {
        string s = v[i].substr(k, j);
        if (aux[s] == 0) {
          ++mp[s];
          subs[i].push_back(s);
          ++aux[s];
        }
      }
    }
    aux.clear();
  }
  for (int i = 0; i < n; ++i) {
    for (auto e : subs[i]) {
      if (mp[e] == 1) {
        cout << e << '\n';
        break;
      }
    }
  }
  return 0;
}
