#include <bits/stdc++.h>
using namespace std;
const int maxn = 70070;
map<pair<long long, int>, set<int> > qtd;
char str[20];
int main() {
  int n;
  scanf("%d", &n);
  vector<string> ful;
  for (int e = 0; e < n; e++) {
    scanf("%s", str);
    ful.push_back(str);
    int len = strlen(str);
    for (int f = 0; f < len; f++) {
      long long cur = 0;
      int sle = 0;
      for (int g = f; g < len; g++) {
        int id = str[g] - '0' + 1;
        cur = (cur * 10) + id;
        sle++;
        qtd[make_pair(cur, sle)].insert(e);
      }
    }
  }
  for (int e = 0; e < n; e++) {
    int len = ful[e].size();
    int size = len, in = 0, ed = len - 1;
    for (int f = 0; f < len; f++) {
      long long cur = 0;
      int sle = 0;
      for (int g = f; g < len; g++) {
        int id = ful[e][g] - '0' + 1;
        cur = (cur * 10) + id;
        sle++;
        if (qtd[make_pair(cur, sle)].size() == 1) {
          if (size > sle) {
            size = sle;
            in = f;
            ed = g;
          }
        }
      }
    }
    for (int f = in; f <= ed; f++) printf("%c", ful[e][f]);
    printf("\n");
  }
  return 0;
}
