#include <bits/stdc++.h>
using namespace std;
const int MAX = 70005;
unordered_map<string, bool> ok;
unordered_map<string, int> m;
vector<string> subs[MAX];
bool comp(string a, string b) { return a.length() < b.length(); }
char s2[15];
int main() {
  int n;
  cin >> n;
  m.reserve(1024);
  m.max_load_factor(0.25);
  ok.reserve(1024);
  ok.max_load_factor(0.25);
  for (int i = 0; i < n; i++) {
    scanf("%s", s2);
    string second = s2;
    int l = 9;
    ok.clear();
    for (int j = 0; j < l; j++) {
      for (int k = 1; k <= l - j; k++) {
        string sub = second.substr(j, k);
        if (!ok[sub]) {
          ok[sub] = true;
          subs[i].push_back(second.substr(j, k));
          m[second.substr(j, k)] += 1;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    sort(subs[i].begin(), subs[i].end(), comp);
  }
  for (int i = 0; i < n; i++) {
    int minlen = 900;
    string ans = "";
    bool ok = false;
    for (string j : subs[i]) {
      if (ok) {
        break;
      }
      if (m[j] == 1) {
        for (char i : j) {
          printf("%c", i);
        }
        printf("\n");
        ok = true;
      }
    }
  }
}
