#include <bits/stdc++.h>
using namespace std;
const int MAXN = 9;
const long long P = 937;
const long long start = 'a';
int n;
vector<string> v;
vector<string> res;
map<long long, int> c[MAXN + 1];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  v.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < MAXN; ++j) {
      long long h = 0;
      for (int k = 1; j + k <= MAXN; ++k) {
        h *= P;
        h += v[i][j + k - 1];
        ++c[k][h];
      }
    }
  }
  res.resize(n);
  for (int i = 0; i < n; ++i) {
    vector<long long> h(MAXN, 0);
    bool flag = false;
    for (int k = 1; k <= MAXN && !flag; ++k) {
      for (int j = 0; j + k <= MAXN; ++j) {
        h[j] *= P;
        h[j] += v[i][j + k - 1];
        --c[k][h[j]];
      }
      for (int j = 0; j + k <= MAXN && !flag; ++j) {
        if (!c[k][h[j]]) {
          res[i] = v[i].substr(j, k);
          flag = true;
        }
      }
      for (int j = 0; j + k <= MAXN; ++j) {
        ++c[k][h[j]];
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << res[i] << "\n";
  }
}
