#include <bits/stdc++.h>
using namespace std;
const long long inf = (long long)1e18;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);
const double eps = (double)1e-9;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};
const int N = 100500;
string s[N];
int n, len[N];
map<string, int> cnt;
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    len[i] = (int)s[i].size();
    vector<string> v;
    for (int j = 0; j < len[i]; j++) {
      string cur = "";
      for (int k = j; k < len[i]; k++) {
        cur += s[i][k];
        v.push_back(cur);
      }
    }
    sort(v.begin(), v.end());
    int cur = unique(v.begin(), v.end()) - v.begin();
    for (int i = 0; i < cur; i++) cnt[v[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    int ans = 10;
    int pos;
    for (int j = 0; j < len[i]; j++) {
      string cur = "";
      for (int k = j; k < len[i]; k++) {
        if (k - j + 1 >= ans) break;
        cur += s[i][k];
        if (cnt[cur] == 1) {
          ans = min(ans, k - j + 1);
          pos = j;
          break;
        }
      }
      if (ans == 1) break;
    }
    for (int j = pos; j <= pos + ans - 1; j++) cout << s[i][j];
    cout << endl;
  }
  return 0;
}
