#include <bits/stdc++.h>
using namespace std;
char str[70010][15];
struct tree {
  tree* next[10];
  int num;
  tree() {
    memset(next, NULL, sizeof(next));
    num = 1;
  }
} root;
int st, lent;
void build(int s, char* str) {
  tree* p = &root;
  tree* q;
  int len = strlen(str);
  for (int i = s; i < len; i++) {
    int id = str[i] - '0';
    if (p->next[id] != NULL) {
      p->next[id]->num++;
      p = p->next[id];
    } else {
      q = new tree;
      p->next[id] = q;
      p = p->next[id];
    }
  }
}
int findd(int s, char* str) {
  tree* p = &root;
  int len = strlen(str);
  for (int i = s; i < len; i++) {
    int id = str[i] - '0';
    if (p->next[id] == NULL) return 0;
    p = p->next[id];
    if (p->num == 0) {
      if (i - s < lent) {
        lent = i - s;
        st = s;
        return 0;
      }
    }
  }
}
void solve1(int s, char* str) {
  tree* p = &root;
  int len = strlen(str);
  for (int i = s; i < len; i++) {
    int id = str[i] - '0';
    if (p->next[id] == NULL) return;
    p = p->next[id];
    p->num--;
  }
}
void solve2(int s, char* str) {
  tree* p = &root;
  int len = strlen(str);
  for (int i = s; i < len; i++) {
    int id = str[i] - '0';
    if (p->next[id] == NULL) return;
    p = p->next[id];
    p->num++;
  }
}
int main() {
  int n;
  root.num = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", str[i]);
    for (int j = 0; str[i][j] != '\0'; j++) build(j, str[i]);
  }
  for (int i = 0; i < n; i++) {
    lent = 1e9 + 7;
    for (int j = 0; str[i][j] != '\0'; j++) solve1(j, str[i]);
    for (int j = 0; str[i][j] != '\0'; j++) findd(j, str[i]);
    for (int j = 0; str[i][j] != '\0'; j++) solve2(j, str[i]);
    for (int j = st; j <= st + lent; j++) printf("%c", str[i][j]);
    printf("\n");
  }
  return 0;
}
