#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  string s[70005];
  map<long long, int> selfcnt[70005];
  map<long long, int> mapcnt;
  cin >> n;
  for (int i = 0, _i = (n); i < _i; ++i) cin >> s[i];
  for (int i = 0, _i = (n); i < _i; ++i) {
    for (int j = 0, _j = (9); j < _j; ++j) {
      long long curr = (long long)(1e9);
      for (int k = (j), _k = (9); k < _k; ++k) {
        int len = k - j + 1;
        curr = curr * 10 + (s[i][k] - '0');
        mapcnt[curr]++;
        selfcnt[i][curr]++;
      }
    }
  }
  for (int i = 0, _i = (n); i < _i; ++i) {
    int ansLen = 10, ind;
    for (int j = 0, _j = (9); j < _j; ++j) {
      long long cur = 0, curr = (long long)(1e9);
      for (int k = (j), _k = (9); k < _k; ++k) {
        int len = k - j + 1;
        curr = curr * 10 + (s[i][k] - '0');
        if (mapcnt[curr] == selfcnt[i][curr] && len < ansLen) {
          ansLen = len;
          ind = j;
        }
      }
    }
    cout << s[i].substr(ind, ansLen) << '\n';
  }
}
