#include <bits/stdc++.h>
using namespace std;
map<string, int> XD;
const int N = 70005;
int n;
string a[N];
char wcz[1000];
int main() {
  scanf("%d", &n);
  for (int I = 0; I < n; ++I) {
    scanf("%s", wcz);
    a[I] = wcz;
    set<string> ss;
    for (int i = 0; i < 9; ++i) {
      string sl = "";
      for (int j = i; j < 9; ++j) {
        sl += a[I][j];
        ss.insert(sl);
      }
    }
    for (auto xd : ss) {
      XD[xd]++;
    }
  }
  for (int I = 0; I < n; ++I) {
    string res = "dskjfhdskfjhakfjadshfkjdshflkjasdfhlkdasjhflkdsaf";
    for (int i = 0; i < 9; ++i) {
      string sl = "";
      for (int j = i; j < 9; ++j) {
        sl += a[I][j];
        if (XD[sl] == 1) {
          if (res.size() > sl.size()) res = sl;
        }
      }
    }
    printf("%s\n", res.c_str());
  }
  return 0;
}
