#include <bits/stdc++.h>
using namespace std;
map<string, int> valid;
string phoneNumber[100000];
void addSubstrings(int index) {
  vector<string> substringsToAdd;
  for (int i = 0; i < 9; i++) {
    string tmp;
    tmp += phoneNumber[index][i];
    substringsToAdd.push_back(tmp);
    int keepo = valid[tmp];
    if (keepo == 0) {
      valid[tmp] = index + 1;
    } else if (keepo != index + 1 && keepo != -1) {
      valid[tmp] = -1;
    }
  }
  for (int i = 2; i <= 9; i++) {
    int currSize = substringsToAdd.size();
    int startingIndex = currSize - (9 - (i - 2));
    for (int k = i - 1; k < phoneNumber[index].size(); k++) {
      string tmp = substringsToAdd[startingIndex + (k - (i - 1))];
      tmp += phoneNumber[index][k];
      substringsToAdd.push_back(tmp);
      int keepo = valid[tmp];
      if (keepo == 0) {
        valid[tmp] = index + 1;
      } else if (keepo != index + 1 && keepo != -1) {
        valid[tmp] = -1;
      }
    }
  }
}
bool isValid(string a) {
  if (a.size() > 0 && valid[a] != -1) return 1;
  return 0;
}
string solve(int index) {
  int left = -1, right = 0;
  string result, toCheck;
  result = phoneNumber[index];
  toCheck += phoneNumber[index][0];
  if (toCheck.size() < result.size() && isValid(toCheck)) {
    result = toCheck;
  }
  while (right < phoneNumber[index].size() - 1) {
    do {
      right++;
      toCheck += phoneNumber[index][right];
    } while (!isValid(toCheck) && right < phoneNumber[index].size() - 1);
    while (isValid(toCheck) && left <= right) {
      if (toCheck.size() < result.size()) {
        result = toCheck;
      }
      toCheck.erase(0, 1);
      left++;
    }
  }
  return result;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> phoneNumber[i];
    addSubstrings(i);
  }
  for (int i = 0; i < n; i++) {
    cout << solve(i) << endl;
  }
  return 0;
}
