#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int f(string s) {
  int res = 0;
  for (char c : s) res = (res * 10) + (c - '0');
  return res;
}
int main() {
  iostream::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<string> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  unordered_map<string, int> q;
  for (int i = 0; i < n; i++) {
    unordered_map<string, int> w;
    for (int j = 0; j < 9; j++) {
      for (int k = j; k < 9; k++) {
        string c = a[i].substr(j, k - j + 1);
        if (w[c]) continue;
        w[c]++;
        q[c]++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    bool ch = 0;
    for (int len = 1; len <= 9 && !ch; len++) {
      for (int j = 0; j + len - 1 < 9 && !ch; j++) {
        if (q[a[i].substr(j, len)] == 1) {
          cout << a[i].substr(j, len) << '\n';
          ch = 1;
        }
      }
    }
  }
  return 0;
}
