#include <bits/stdc++.h>
using namespace std;
const int N = 70005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;
int n;
char s[N][15];
map<string, int> mp;
map<string, bool> used;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    scanf("%s", &s[i]);
    for (int j = 0; j < 9; j++) {
      string S = "";
      for (int h = j; h < 9; h++) {
        S += s[i][h];
        if (used[S] == false) {
          mp[S]++;
          used[S] = true;
        }
      }
    }
    used.clear();
  }
  for (int i = 1; i <= n; i++) {
    string answ;
    int len = 15;
    for (int j = 0; j < 9; j++) {
      string S = "";
      for (int h = j; h < 9; h++) {
        if (h - j >= len) break;
        S += s[i][h];
        if (mp[S] == 1) {
          answ = S;
          len = h - j;
        }
      }
    }
    cout << answ << endl;
  }
  return 0;
}
