#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<string> v;
  map<string, int> numappear;
  for (int k = 0; k < N; k++) {
    set<string> st3;
    string s;
    cin >> s;
    v.push_back(s);
    for (int i = 0; i < 9; i++) {
      string st = "";
      for (int j = i; j < 9; j++) {
        st += s[j];
        st3.insert(st);
      }
    }
    for (auto it = st3.begin(); it != st3.end(); it++) {
      numappear[*it] += 1;
    }
  }
  for (int k = 0; k < N; k++) {
    string s = v[k];
    int minlen = 1;
    int maxlen = 9;
    string ans = "";
    while (minlen != maxlen) {
      int mid = (minlen + maxlen) / 2;
      bool uniq = false;
      for (int i = 0; i <= 9 - mid; i++) {
        string st = "";
        for (int j = i; j < i + mid; j++) {
          st += s[j];
        }
        if (numappear[st] == 1) {
          uniq = true;
        }
      }
      if (uniq) {
        maxlen = mid;
      } else {
        minlen = mid + 1;
      }
    }
    int finlen = minlen;
    for (int i = 0; i <= 9 - finlen; i++) {
      string st = "";
      for (int j = i; j < i + finlen; j++) {
        st += s[j];
      }
      if (numappear[st] == 1) {
        ans = st;
      }
    }
    cout << ans << endl;
  }
}
