#include <bits/stdc++.h>
using namespace std;
const int N = 7e4;
int n;
string ar[N + 2];
map<string, int> cnt;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> ar[i];
    set<string> tmp;
    for (int j = 1; j <= 9; j++) {
      for (int k = 0; k <= 9 - j; k++) {
        string sub = ar[i].substr(k, j);
        tmp.insert(sub);
      }
    }
    for (auto i : tmp) {
      cnt[i]++;
    }
  }
  for (int i = 1; i <= n; i++) {
    bool done = 0;
    for (int j = 1; j <= 9 && !done; j++) {
      for (int k = 0; k <= 9 - j && !done; k++) {
        string sub = ar[i].substr(k, j);
        if (cnt[sub] == 1) {
          cout << sub << '\n';
          done = 1;
        }
      }
    }
  }
  return 0;
}
