#include <bits/stdc++.h>
using namespace std;
const int INF = 2000000005;
const long long INFLL = 1000000000000000002ll;
const long long MOD = 1000000007;
inline long long min(long long a, long long b, long long c) {
  return min(min(a, b), c);
}
inline long long min(long long a, long long b, long long c, long long d) {
  return min(min(min(a, b), c), d);
}
inline long long max(long long a, long long b, long long c) {
  return max(max(a, b), c);
}
inline long long max(long long a, long long b, long long c, long long d) {
  return max(max(max(a, b), c), d);
}
int A[70005][10], N;
map<pair<int, int>, int> M;
string query(int idx) {
  int low = 99, bl = 0, br = 0;
  for (int i = (0); i <= (8); i++) {
    int x = 0;
    for (int j = (i); j <= (8); j++) {
      x = 10 * x + A[idx][j];
      M[{x, j - i + 1}]--;
    }
  }
  for (int i = (0); i <= (8); i++) {
    int x = 0;
    for (int j = (i); j <= (8); j++) {
      x = 10 * x + A[idx][j];
      if (M[{x, j - i + 1}] == 0 && j - i + 1 < low) {
        low = j - i + 1;
        bl = i, br = j;
      }
    }
  }
  for (int i = (0); i <= (8); i++) {
    int x = 0;
    for (int j = (i); j <= (8); j++) {
      x = 10 * x + A[idx][j];
      M[{x, j - i + 1}]++;
    }
  }
  string ret = "";
  for (int i = (bl); i <= (br); i++) ret += (char)(A[idx][i] + '0');
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> N;
  string s;
  for (int idx = (1); idx <= (N); idx++) {
    cin >> s;
    for (int i = (0); i <= (8); i++) A[idx][i] = s[i] - '0';
    for (int i = (0); i <= (8); i++) {
      int x = 0;
      for (int j = (i); j <= (8); j++) {
        x = 10 * x + A[idx][j];
        M[{x, j - i + 1}]++;
      }
    }
  }
  for (int i = (1); i <= (N); i++) cout << query(i) << "\n";
}
