#include <bits/stdc++.h>
using namespace std;
const int N = 70005;
const unsigned long long p1 = 5557;
const int mod = 998244853;
const int p2 = 2333;
struct node {
  unsigned long long x;
  int y;
  node() {}
  node(unsigned long long x, int y) : x(x), y(y) {}
  friend bool operator<(node a, node b) {
    return a.x < b.x || (a.x == b.x && a.y < b.y);
  }
  friend node operator*(node a, node b) {
    return node(a.x * b.x, 1ll * a.y * b.y % mod);
  }
  friend node operator+(node a, node b) {
    return node(a.x + b.x, (a.y + b.y) % mod);
  }
  friend node operator-(node a, node b) {
    return node(a.x - b.x, (a.y - b.y + mod) % mod);
  }
} hs[N][11], p[N], P;
int n, al, ar;
char s[N][11];
map<node, int> mp;
node hsh(int k, int l, int r) { return hs[k][r] - hs[k][l - 1] * p[r - l + 1]; }
int main() {
  int i, j, k;
  scanf("%d", &n);
  P = node(p1, p2);
  p[0] = node(1, 1);
  for (i = 1; i <= 10; i++) p[i] = p[i - 1] * P;
  for (i = 1; i <= n; i++) {
    scanf("%s", s[i] + 1);
    hs[i][0] = node(0, 0);
    for (j = 1; j <= 9; j++)
      hs[i][j] = hs[i][j - 1] * P + node((unsigned long long)s[i][j], s[i][j]);
    for (j = 1; j <= 9; j++)
      for (k = j; k <= 9; k++) mp[hsh(i, j, k)]++;
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= 9; j++)
      for (k = j; k <= 9; k++) mp[hsh(i, j, k)]--;
    al = 1;
    ar = 9;
    for (j = 1; j <= 9; j++)
      for (k = j; k <= 9; k++)
        if (k - j < ar - al && !mp[hsh(i, j, k)]) {
          al = j, ar = k;
        }
    for (j = 1; j <= 9; j++)
      for (k = j; k <= 9; k++) mp[hsh(i, j, k)]++;
    for (j = al; j <= ar; j++) printf("%c", s[i][j]);
    printf("\n");
  }
  return 0;
}
