#include <bits/stdc++.h>
using namespace std;
const int N = 70000 + 10;
int n;
string s[N], ans[N];
int res[N];
char st[100];
map<string, int> mp, mp2;
void insert(string &s) {
  int n = s.length();
  mp2.clear();
  string t;
  for (int i = 0; i < n; ++i) {
    t = "";
    for (int j = i; j < n; ++j) {
      t += s[j];
      ++mp2[t];
    }
  }
  for (auto x : mp2) ++mp[x.first];
}
void get(string &s, int idx) {
  res[idx] = 1e9;
  int n = s.length();
  string t;
  for (int i = 0; i < n; ++i) {
    t = "";
    for (int j = i; j < n; ++j) {
      t += s[j];
      if (mp[t] == 1) {
        if (t.length() < res[idx]) {
          res[idx] = t.length();
          ans[idx] = t;
        }
      }
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", st);
    s[i] = st;
    insert(s[i]);
  }
  for (int i = 0; i < n; ++i) get(s[i], i);
  for (int i = 0; i < n; ++i) printf("%s\n", ans[i].c_str());
  return 0;
}
