#include <bits/stdc++.h>
using namespace std;
void aps554(long long int n = 10) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(n) << fixed;
}
long long int M = 1e9 + 7;
long long int M1 = 998244353;
int32_t main() {
  aps554();
  long long int n;
  cin >> n;
  vector<string> arr(n);
  for (long long int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  unordered_map<string, long long int> pos, pre;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < 9; j++) {
      for (long long int k = 1; k <= 9 - j; k++) {
        pos[arr[i].substr(j, k)]++;
      }
    }
  }
  for (long long int i = 0; i < n; i++) {
    long long int done = 1;
    for (long long int j = 0; j < 9; j++) {
      for (long long int k = 1; k <= 9 - j; k++) {
        pos[arr[i].substr(j, k)]--;
      }
    }
    for (long long int k = 1; done && k <= 9; k++) {
      for (long long int j = 0; done && j < 9 - k + 1; j++) {
        if (pos[arr[i].substr(j, k)] == 0 && pre[arr[i].substr(j, k)] == 0) {
          cout << arr[i].substr(j, k) << "\n";
          done = 0;
        }
      }
    }
    for (long long int j = 0; j < 9; j++) {
      for (long long int k = 1; k <= 9 - j; k++) {
        pre[arr[i].substr(j, k)]++;
      }
    }
  }
}
