#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int cti(char c) { return (int)(c - '0'); }
const int P = 10;
map<pair<int, long long>, unordered_set<int>> mem;
const int N = 70000 + 100;
string s[N];
const int D = 9;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < D; ++j) {
      long long h = 0;
      bool seen = 0;
      int run = 0;
      for (int k = j; k < D; ++k) {
        if (cti(s[i][k]) != 0) {
          seen = 1;
        }
        if (!seen) {
          ++run;
        }
        h = h * P + cti(s[i][k]);
        auto it = mem.find(make_pair(run, h));
        if (it == mem.end()) {
          mem[make_pair(run, h)] = unordered_set<int>();
        }
        mem[make_pair(run, h)].insert(i);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    int mind = INF;
    int mini = -1;
    for (int j = 0; j < D; ++j) {
      long long h = 0;
      bool seen = 0;
      int run = 0;
      for (int k = j; k < D; ++k) {
        if (cti(s[i][k]) != 0) {
          seen = 1;
        }
        if (!seen) {
          ++run;
        }
        h = h * P + cti(s[i][k]);
        auto it = mem.find(make_pair(run, h));
        if (it->second.size() == 1) {
          int cur = k - j + 1;
          if (cur < mind) {
            mind = cur;
            mini = j;
          }
        }
      }
    }
    for (int j = mini; j < mini + mind; ++j) {
      cout << s[i][j];
    }
    cout << endl;
  }
  return 0;
}
