#include <bits/stdc++.h>
using namespace std;
map<string, int> mp[9];
set<string> trash;
bool yes[70004];
string ans[70004];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s, t;
    cin >> s;
    for (int x = 0; x < 9; x++) {
      t = string();
      for (int y = x; y < 9; y++) {
        t += s[y];
        if (mp[y - x].count(t) and mp[y - x][t] != i) {
          mp[y - x].erase(t);
          trash.insert(t);
        } else if (!trash.count(t))
          mp[y - x][t] = i;
      }
    }
  }
  for (int i = 0; i < 9; i++) {
    for (auto p : mp[i]) {
      string key = p.first;
      int val = p.second;
      if (!yes[val]) {
        yes[val] = 1;
        ans[val] = key;
      }
    }
  }
  for (int i = 0; i < n; i++) cout << ans[i] << '\n';
}
