#include <bits/stdc++.h>
using namespace std;
int n, m, i, b, j, mini, k, h;
map<string, int> mpgn;
map<string, int> mp;
string s[90000], c, ansstring;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> s[i];
    mp.clear();
    for (j = 0; j < s[i].length(); j++)
      for (k = j; k < s[i].length(); k++) {
        c = "";
        for (b = j; b <= k; b++) c += s[i][b];
        h = ++mp[c];
        if (h == 1) mpgn[c]++;
      }
  }
  for (i = 1; i <= n; i++) {
    mini = 10000;
    for (j = 0; j < s[i].length(); j++)
      for (k = j; k < s[i].length(); k++) {
        c = "";
        for (b = j; b <= k; b++) c += s[i][b];
        if (mpgn[c] == 1)
          if (mini > k - j + 1) {
            mini = min(mini, k - j + 1);
            ansstring = c;
          }
      }
    cout << ansstring << endl;
  }
}
