#include <bits/stdc++.h>
using namespace std;
string s[100005];
map<int, map<int, int> > m1, v1;
long long p1 = 37LL;
long long p2 = 101197;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    v1.clear();
    for (int j = 0; j < 9; j++) {
      long long h1 = 0, h2 = 0;
      for (int k = j; k < 9; k++) {
        h1 = h1 * p1 + (long long)(s[i][k] - '0' + 1LL);
        h1 %= 1000000007;
        h2 = h2 * p2 + (long long)(s[i][k] - '0' + 1LL);
        h2 %= 1000000007;
        if (v1[h1][h2] == 0) {
          m1[h1][h2]++;
          v1[h1][h2] = 1;
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    int ans = 9;
    string s1 = s[i];
    for (int j = 0; j < 9; j++) {
      long long h1 = 0, h2 = 0;
      string v2;
      for (int k = j; k < 9; k++) {
        h1 = h1 * p1 + (long long)(s[i][k] - '0' + 1LL);
        h1 %= 1000000007;
        v2 += s[i][k];
        h2 = h2 * p2 + (long long)(s[i][k] - '0' + 1LL);
        h2 %= 1000000007;
        if (m1[h1][h2] == 1) {
          if (k - j + 1 < ans) {
            ans = k - j + 1;
            s1 = v2;
          }
        }
      }
    }
    cout << s1 << '\n';
  }
}
