#include <bits/stdc++.h>
using namespace std;
int n;
string s[70005], Ti;
unordered_map<string, int> seg, subseg[70005];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    for (int j = 0; j <= 8; j++) {
      for (int k = j; k <= 8; k++) {
        seg[s[i].substr(j, k - j + 1)]++;
        subseg[i][s[i].substr(j, k - j + 1)]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    bool done = 0;
    for (int j = 1; j <= 9; j++) {
      for (int k = 0; k <= 8 - j + 1; k++) {
        Ti = s[i].substr(k, j);
        int t = seg[Ti] - subseg[i][Ti];
        if (t == 0) {
          cout << Ti << endl;
          done = 1;
          break;
        }
      }
      if (done) break;
    }
  }
  return 0;
}
