#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> nums(n);
  vector<string> nums_str(n);
  unordered_map<string, int> counts;
  for (int i = 0; i < n; i++) {
    cin >> nums[i];
    nums_str[i] = to_string(nums[i]);
    unordered_map<string, bool> used;
    for (int l = 1; l <= 9; l++) {
      for (int j = 0; j <= 9 - l; j++) {
        string part = nums_str[i].substr(j, l);
        if (used.find(part) == used.end()) {
          used[part] = true;
          if (counts.find(part) == counts.end()) counts[part] = 0;
          counts[part]++;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int l = 1; l <= 9; l++) {
      for (int j = 0; j <= 9 - l; j++) {
        string part = nums_str[i].substr(j, l);
        if (counts[part] == 1) {
          cout << part << "\n";
          goto end_number;
        }
      }
    }
  end_number : {}
  }
  return 0;
}
