#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_gt = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using pq_lt = priority_queue<T, vector<T>, less<T>>;
string str[100100];
map<string, set<int>> mm[10];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> str[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= 9; j++) {
      for (int k = 0; j + k <= 9; k++) {
        string tmp = str[i].substr(k, j);
        if (mm[j][tmp].size() < 2) mm[j][tmp].insert(i);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j <= 9; ++j) {
      bool flag = false;
      for (int k = 0; j + k <= 9; ++k) {
        string tmp = str[i].substr(k, j);
        if (mm[j][tmp].size() == 1) {
          cout << tmp << endl;
          flag = true;
          break;
        }
      }
      if (flag) {
        break;
      }
    }
  }
}
