#include <bits/stdc++.h>
using namespace std;
const int INF = 1011011011;
const int MAX_N = 70333;
void solve() {
  unordered_map<int, int> mp;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < 9; j++) {
      int x = 1;
      for (int u = j; u < 9; u++) {
        x = x * 10 + s[u] - '0';
        auto& res = mp[x];
        if (res == 0) {
          res = i;
        } else if (res != i) {
          res = -1;
        }
      }
    }
  }
  vector<int> ans(n + 1, numeric_limits<int>::max());
  for (const auto& p : mp) {
    if (p.second != -1) {
      ans[p.second] = min(ans[p.second], p.first);
    }
  }
  for (int i = 1; i <= n; i++) {
    string s = to_string(ans[i]);
    for (int j = 1; j < s.size(); j++) {
      cout << s[j];
    }
    cout << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  solve();
  return 0;
}
