#include <bits/stdc++.h>
using namespace std;
const long long INFL = 1e18 + 7;
const int INF = 1e9 + 7;
const int DAY = 1440;
int v[150][150];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  map<string, pair<int, int>> v;
  vector<string> st;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < 9; j++) {
      string s1 = "";
      for (int k = j; k < 9; k++) {
        s1.push_back(s[k]);
        auto it = v.find(s1);
        if (it == v.end()) {
          v.insert(make_pair(s1, make_pair(1, i)));
        } else {
          if ((it->second).second != i) {
            (it->second).first++;
            (it->second).second = i;
          }
        }
      }
    }
    st.push_back(s);
  }
  for (int i = 0; i < n; i++) {
    bool b = 1;
    for (int j = 1; j <= 9 && b; j++) {
      for (int k = 0; k <= 9 - j && b; k++) {
        string s1 = st[i].substr(k, j);
        if ((v.find(s1)->second).first == 1) {
          cout << s1 << "\n";
          b = 0;
        }
      }
    }
  }
}
