#include <bits/stdc++.h>
using namespace std;
char s[77777][11];
vector<int> g[77777];
int unq[77777 * 50];
pair<int, int> idx[77777 * 50];
int n;
map<long long, int> ctr;
int main() {
  memset(unq, -1, sizeof(unq));
  scanf("%d", &n);
  int ptr = 0;
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
    for (int st = 0; st < 9; ++st) {
      long long val = 0;
      for (int fn = st; fn < 9; ++fn) {
        val = (val * 11 + (s[i][fn] - '0' + 1));
        if (!ctr.count(val)) {
          ctr[val] = ptr++;
        }
        int who = ctr[val];
        if (unq[who] == -1) {
          unq[who] = i;
          idx[who] = make_pair(st, fn);
          g[i].push_back(who);
        } else if (unq[who] != i) {
          unq[who] = -2;
        }
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    pair<int, int> best_xy = make_pair(1, 100);
    for (int pos = 0; pos < (int)(g[i]).size(); ++pos) {
      if (unq[g[i][pos]] >= 0) {
        pair<int, int> p = idx[g[i][pos]];
        if (p.second - p.first < best_xy.second - best_xy.first) {
          best_xy = p;
        }
      }
    }
    for (int pos = best_xy.first; pos <= best_xy.second; ++pos) {
      printf("%c", s[i][pos]);
    }
    printf("\n");
  }
}
