#include <bits/stdc++.h>
using namespace std;
char a[80000][10];
map<long long, int> mp;
int main() {
  int t = 1;
  while (t--) {
    int n;
    scanf("%d", &n);
    for (int u = 0; u < n; u++) {
      scanf("%s", a[u]);
      set<long long> mp2;
      int m = 9;
      for (int i = 0; i < m; i++) {
        long long h = 0;
        long long p = 1;
        for (int j = i; j < m; j++) {
          h += p * a[u][j];
          p = (p * 472882049) % 1000000007;
          mp2.insert(h);
        }
      }
      for (set<long long>::iterator it = mp2.begin(); it != mp2.end(); it++) {
        mp[*it]++;
      }
    }
    for (int u = 0; u < n; u++) {
      int ans = INT_MAX;
      int si, ei;
      int m = 9;
      for (int i = 0; i < m; i++) {
        long long h = 0;
        long long p = 1;
        for (int j = i; j < m; j++) {
          int l = j - i + 1;
          h += p * a[u][j];
          p = (p * 472882049) % 1000000007;
          if (l < ans && mp[h] == 1) {
            ans = l;
            si = i, ei = j;
          }
        }
      }
      for (int i = si; i < ei + 1; i++) putchar(a[u][i]);
      putchar('\n');
    }
  }
}
