#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    int n, i, j, k;
    cin >> n;
    vector<string> v[n];
    int vis[n][45];
    memset(vis, 0, sizeof(vis));
    map<string, int> mp;
    string p;
    for (i = 0; i < n; i++) {
      string temp;
      cin >> temp;
      for (j = 1; j <= 9; j++) {
        for (k = 0; k <= 9 - j; k++) {
          v[i].push_back(temp.substr(k, j));
        }
      }
    }
    for (i = 0; i < n; i++) {
      map<string, int> m1;
      for (j = 0; j < int(v[i].size()); j++) {
        if (m1[v[i][j]] == 0) vis[i][j] = 1;
        m1[v[i][j]]++;
      }
    }
    for (i = 0; i < n; i++) {
      for (j = 0; j < int(v[i].size()); j++) {
        if (vis[i][j] == 1) mp[v[i][j]]++;
      }
    }
    for (i = 0; i < n; i++) {
      for (j = 0; j < int(v[i].size()); j++) {
        if (mp[v[i][j]] == 1) {
          cout << v[i][j] << '\n';
          break;
        }
      }
    }
  }
  return 0;
}
