#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  unordered_map<int, int> cnt[10];
  string arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = 0; i < n; i++) {
    string s = arr[i];
    for (int l = 1; l < 10; l++) {
      unordered_set<int> subst;
      for (int j = 0; j + l < 10; j++) {
        int cur = 0;
        int base = 1;
        for (int t = j + l - 1; t >= j; t--) {
          cur += base * (s[t] - '0');
          base *= 10;
        }
        subst.insert(cur);
      }
      for (auto elem : subst) {
        cnt[l][elem];
        cnt[l][elem] += 1;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    string s = arr[i];
    bool flag = true;
    for (int l = 1; l < 10 && flag; l++) {
      for (int j = 0; j + l < 10 && flag; j++) {
        int cur = 0;
        int base = 1;
        for (int t = j + l - 1; t >= j; t--) {
          cur += base * (s[t] - '0');
          base *= 10;
        }
        if (cnt[l][cur] == 1) {
          cout << s.substr(j, l) << "\n";
          flag = false;
        }
      }
    }
  }
}
