#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, l, i, j;
  unordered_map<string, set<int>> c;
  vector<string> s(70179);
  for (cin >> n, l = 0; l < n; l++)
    for (cin >> s[l], i = 1; i <= 9; i++)
      for (j = 0; j <= 9 - i; j++) c[s[l].substr(j, i)].insert(l);
  for (l = 0; l < n; l++)
    for (i = 1; i <= 9; i++)
      for (j = 0; j <= 9 - i; j++) {
        string u = s[l].substr(j, i);
        if (u[0] != 'a' && c[u].size() == 1) {
          s[l] = "aaaaaaaaa";
          cout << u << endl;
        }
      }
}
