#include <bits/stdc++.h>
using namespace std;
int n, mn[70005];
string s[70005], t, ans[70005];
map<string, int> m, q;
int32_t main() {
  ios_base ::sync_with_stdio(0);
  cin.tie();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    mn[i] = 9;
    q.clear();
    cin >> s[i];
    ans[i] = s[i];
    for (int j = 0; j < 9; j++) {
      t = "";
      for (int k = j; k < 9; k++) {
        t += s[i][k];
        if (!q[t]) m[t]++;
        q[t] = 1;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 9; j++) {
      t = "";
      for (int k = j; k < 9; k++) {
        t += s[i][k];
        if (m[t] == 1 && k - j + 1 < mn[i]) {
          mn[i] = k - j + 1;
          ans[i] = t;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << '\n';
  }
}
