#include <bits/stdc++.h>
using namespace std;
int n, k, x, y, sum, cnt, ans;
char s[15];
map<string, int> m;
string t[70005];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", s);
    t[i] = s;
    set<string> s;
    for (int j = 0; j < 9; j++) {
      for (int k = j; k < 9; k++) {
        s.insert(t[i].substr(j, k - j + 1));
      }
    }
    for (auto it : s) m[it]++;
  }
  for (int i = 0; i < n; i++) {
    bool ok = false;
    for (int j = 1; j <= 9; j++) {
      for (int k = 0; k + j - 1 < 9; k++) {
        if (m[t[i].substr(k, j)] == 1) {
          ok = true;
          printf("%s\n", t[i].substr(k, j).c_str());
          break;
        }
      }
      if (ok) break;
    }
  }
  return 0;
}
