#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1.);
const long long INF = 1000 * 1000 * 1000 + 1;
const long long MOD = 1000 * 1000 * 1000 + 7;
int subInt(int n, int l, int r, int len) {
  int m = 1;
  for (int i = 0; i < len - l - 1; ++i) {
    m *= 10;
  }
  n %= m;
  m = 1;
  for (int i = 0; i < len - r - 2; ++i) {
    m *= 10;
  }
  return n / m;
}
void process(int& s, vector<unordered_map<int, int>>& substr) {
  vector<unordered_map<int, int>> used(11);
  for (int len = 1; len < 10; ++len) {
    for (int pos = 0; pos < 10 - len; ++pos) {
      int cur = subInt(s, pos, pos + len - 1, 10);
      if (used[len][cur]) {
        continue;
      }
      if (substr[len].find(cur) == substr[len].end()) {
        substr[len][cur] = 1;
      } else {
        ++substr[len][cur];
      }
      used[len][cur] = 1;
    }
  }
}
int getLen(int n) {
  if (!n) return 1;
  int res = 0;
  while (n) {
    n /= 10;
    ++res;
  }
  return res;
}
void solve(int s, vector<unordered_map<int, int>>& substr) {
  for (int len = 1; len < 10; ++len) {
    for (int pos = 0; pos < 10 - len; ++pos) {
      int cur = subInt(s, pos, pos + len - 1, 10);
      if (substr[len][cur] == 1) {
        int cLen = getLen(cur);
        for (int i = 0; i < len - cLen; ++i) {
          cout << "0";
        }
        cout << cur << endl;
        return;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<unordered_map<int, int>> substr(11);
  vector<int> numbers(n);
  for (int i = 0; i < n; ++i) {
    cin >> numbers[i];
    process(numbers[i], substr);
  }
  for (int number : numbers) {
    solve(number, substr);
  }
  return 0;
}
