#include <bits/stdc++.h>
using namespace std;
const long long mod = (long long)(1e+9) + 7;
const long long INF = (long long)1000000007 * 1000000007;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
string s[70000];
int n;
vector<string> u[70000];
map<string, int> mp;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < 9; j++) {
      for (int k = j; k < 9; k++) {
        string z = s[i].substr(j, k - j + 1);
        mp[z]++;
        u[i].push_back(z);
      }
    }
    sort(u[i].begin(), u[i].end());
  }
  for (int i = 0; i < n; i++) {
    int ma = 10;
    string ans;
    for (int j = 0; j < u[i].size(); j++) {
      int c = 1;
      string cur = u[i][j];
      while (j + 1 < u[i].size() && u[i][j] == u[i][j + 1]) {
        c++;
        j++;
      }
      int cc = mp[cur];
      if (c == cc) {
        if (ma > cur.size()) {
          ma = cur.size();
          ans = cur;
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}
