#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long add(long long a, long long b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
  return a;
}
long long sub(long long a, long long b) {
  a -= b;
  if (a < 0) a += 1000000007;
  return a;
}
long long mul(long long a, long long b) { return (a * b) % 1000000007; }
void solve() {
  int n;
  cin >> n;
  map<string, int> m[10];
  string s[n];
  for (int i = 0; i < (n); ++i) {
    cin >> s[i];
    map<string, int> mapp[10];
    for (int j = 0; j < (9); ++j) {
      string temp = "";
      for (int k = j; k < 9; k++) {
        temp += s[i][k];
        mapp[temp.size()][temp]++;
      }
    }
    for (int j = 0; j < (10); ++j)
      for (auto p : mapp[j]) m[j][p.first]++;
  }
  for (int i = 0; i < (n); ++i) {
    for (int len = 1; len < (10); ++len) {
      for (int j = 0; j < (10 - len); ++j) {
        string temp = s[i].substr(j, len);
        if (m[len][temp] == 1) {
          cout << temp << "\n";
          goto outside;
        }
      }
    }
  outside:;
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tt = 1;
  while (tt--) solve();
}
