#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define _CRT_SECURE_NO_WARNINGS

#pragma intrinsic sync_with_stdio
#pragma intrinsic size
#pragma intrinsic substr
#pragma intrinsic resize
#pragma intrinsic printf
#pragma intrinsic scanf

#include <bits/stdc++.h>

#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define F first
#define S second
#define uint unsigned int

#define forn(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main()
{
    //freopen("input.txt ", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cin.tie(0);
    //cout.tie(0);
    ios_base::sync_with_stdio(false);
	int n;
	scanf("%d", &n);
	vector <string> a(n);
	unordered_map <string, int> d;
	forn(str, n)
	{
		a[str].resize(9);
		scanf("%s", a[str].c_str());
		unordered_map <string, int> dd;
		for(int c = 1; c <= 10; c++)
			for(int i = 0; i <= 10 - c; i++)
			{
				string st = a[str].substr(i, c);
				dd[st] = 1;
			}
		for(auto i:dd)
			d[i.F]++;
	}
	forn(str, n)
	for(int c = 1; c <= 10; c++)
	{
		bool b = false;
			for(int i = 0; i <= 10 - c; i++)
			{
				string st = a[str].substr(i, c);
				if (d[st] == 1) {printf("%s\n", st.c_str()); b = true; break;}
			}
		if (b) break;
	}
    return 0;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define _CRT_SECURE_NO_WARNINGS

//#pragma intrinsic printf
//#pragma intrinsic scanf

#include <bits/stdc++.h>

#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define F first
#define S second
#define uint unsigned int

#define forn(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main()
{
    //freopen("input.txt ", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cin.tie(0);
    //cout.tie(0);
    ios_base::sync_with_stdio(false);
	int n;
	scanf("%d", &n);
	vector <string> a(n);
	unordered_map <string, int> d;
	forn(str, n)
	{
		a[str].resize(9);
		scanf("%s", a[str].c_str());
		unordered_map <string, int> dd;
		for(int c = 1; c <= 10; c++)
			for(int i = 0; i <= 10 - c; i++)
			{
				string st = a[str].substr(i, c);
				dd[st] = 1;
			}
		for(auto i:dd)
			d[i.F]++;
	}
	forn(str, n)
	for(int c = 1; c <= 10; c++)
	{
		bool b = false;
			for(int i = 0; i <= 10 - c; i++)
			{
				string st = a[str].substr(i, c);
				if (d[st] == 1) {printf("%s\n", st.c_str()); b = true; break;}
			}
		if (b) break;
	}
    return 0;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define _CRT_SECURE_NO_WARNINGS

#pragma intrinsic printf
#pragma intrinsic scanf

#include <bits/stdc++.h>

#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define F first
#define S second
#define uint unsigned int

#define forn(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main()
{
    //freopen("input.txt ", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cin.tie(0);
    //cout.tie(0);
    ios_base::sync_with_stdio(false);
	int n;
	scanf("%d", &n);
	vector <string> a(n);
	unordered_map <string, int> d;
	forn(str, n)
	{
		a[str].resize(9);
		scanf("%s", a[str].c_str());
		unordered_map <string, int> dd;
		for(int c = 1; c <= 10; c++)
			for(int i = 0; i <= 10 - c; i++)
			{
				string st = a[str].substr(i, c);
				dd[st] = 1;
			}
		for(auto i:dd)
			d[i.F]++;
	}
	forn(str, n)
	for(int c = 1; c <= 10; c++)
	{
		bool b = false;
			for(int i = 0; i <= 10 - c; i++)
			{
				string st = a[str].substr(i, c);
				if (d[st] == 1) {printf("%s\n", st.c_str()); b = true; break;}
			}
		if (b) break;
	}
    return 0;
}


#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define _CRT_SECURE_NO_WARNINGS

#include <bits/stdc++.h>

#define pb push_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define F first
#define S second
#define uint unsigned int

#define forn(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main()
{
    //freopen("input.txt ", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //cin.tie(0);
    //cout.tie(0);
    ios_base::sync_with_stdio(false);
	int n;
	scanf("%d", &n);
	vector <string> a(n);
	unordered_map <string, int> d;
	forn(str, n)
	{
		a[str].resize(9);
		scanf("%s", a[str].c_str());
		unordered_map <string, int> dd;
		for(int c = 1; c <= 10; c++)
			for(int i = 0; i <= 10 - c; i++)
			{
				string st = a[str].substr(i, c);
				dd[st] = 1;
			}
		for(auto i:dd)
			d[i.F]++;
	}
	forn(str, n)
	for(int c = 1; c <= 10; c++)
	{
		bool b = false;
			for(int i = 0; i <= 10 - c; i++)
			{
				string st = a[str].substr(i, c);
				if (d[st] == 1) {printf("%s\n", st.c_str()); b = true; break;}
			}
		if (b) break;
	}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define INF INT_MAX
#define all(x) x.begin(),x.end()
void printVector(vector<string> &v)
{
	for(auto x:v)
		cout<<x<<"\n";
}
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        int n;
        cin>>n;
        vector<string> phnos(n);
        for(int i=0;i<n;i++)
            cin>>phnos[i];
        vector<string> ans(n);
        vi visited(n,0);
        for(int i=1;i<=9;i++)
        {
            map<string,int> mp;
            for(int j=0;j<n;j++)
            {
                if(visited[j])
                    continue;
                for(int k=0;k<10-i;k++)
                {
                    string s = phnos[j].substr(k,i);
                    if(mp.find(s)==mp.end())
                        mp.insert({s,j});
                    else
                        mp[s]=-1;
                }
            }
            for(auto x:mp)
            {
                if(x.S!=-1)
                {
                    visited[x.S]=1;
                    ans[x.S] = x.F;
                }
            }
        }
        printVector(ans);
    }
}


#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef pair<int,int> pi;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define INF INT_MAX
#define all(x) x.begin(),x.end()
void printVector(vector<string> &v)
{
	for(auto x:v)
		cout<<x<<"\n";
}
int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        int n;
        cin>>n;
        vector<string> phnos(n);
        for(int i=0;i<n;i++)
            cin>>phnos[i];
        vector<string> ans(n);
        vi visited(n,0);
        for(int i=1;i<=9;i++)
        {
            map<string,int> mp;
            for(int j=0;j<n;j++)
            {
                for(int k=0;k<10-i;k++)
                {
                    string s = phnos[j].substr(k,i);
                    if(mp.find(s)==mp.end())
                        mp.insert({s,j});
                    else if(mp[s]!=j)
                        mp[s]=-1;
                }
            }
            for(auto x:mp)
            {
                //cout<<x.F<<" "<<x.S<<"\n";
                if(x.S!=-1&&visited[x.S]==0)
                {
                    visited[x.S]=1;
                    ans[x.S] = x.F;
                }
            }
        }
        printVector(ans);
    }
}


#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define dep(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
const int maxn=70005,maxm=1000005;
int t[maxm][12],tt=0,c[maxm],v[maxm];
char s[maxn][12];

void ins(char *s,int q)
{
	int p=0;
	for(;*s;s++){
		if(t[p][*s-'0']==0)t[p][*s-'0']=++tt;
		p=t[p][*s-'0'];
		if(v[p]!=q){c[p]++;v[p]=q;}//更新计数数组c和最新的记录位置数组v
	}
	return;
}

int find(char *s)
{
	int p=0,l=0;
	for(;*s;s++){
		l++;
		p=t[p][*s-'0'];
		if(c[p]==1)return l;//返回最小长度
	}
	return 10;
}
int main()
{
	int n;
	scanf("%d",&n);
	memset(v,-1,sizeof v);
	rep(i,0,n-1){
		scanf("%s",s[i]);
		rep(j,0,8){ins(s[i]+j,i);}//建立查询的数组
	}
	rep(i,0,n-1){
		int start=0,len=9;
		rep(j,0,8){
			int u=find(s[i]+j);//查询长度，如果小于答案，更换答案
			if(u<len){
				start=j;
				len=u;
			}
		}
		s[i][start+len]=0;
		printf("%s\n",s[i]+start);
	}
	return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ull unsigned ll
#define pb push_back
#define eb emplace_back
#define INF 1e9
#define sz size()

using namespace std;
struct trie{
    trie *children[10];
    int End=0;
    trie(){
        for(auto &u:children)
            u=nullptr;
    }
};
void add(trie *root,string &st){
    trie *cur=root;
    for(char c:st){
        int indx=c-'0';
        if(cur->children[indx]==nullptr)
            cur->children[indx]=new trie;
        cur=cur->children[indx];
    }
    cur->End++;
}
bool get(trie *root,string &st){
    trie *cur=root;
    for(char c:st){
        int indx=c-'0';
        cur=cur->children[indx];
    }
    cur->End--;
    if(cur->End)
        return false;
    return true;
}
void solve(){
    int n;
    cin >> n;
    vector<string> words;
    while(n--){
        string st;
        cin >> st;
        words.pb(st);
    }
    trie *root=new trie;
    for(string st : words){
        for(int j=st.sz;j>0;j--)
            for(int i=0;i<=st.sz-j;i++){
                string nw=st.substr(i,j);
                add(root,nw);
            }
    }
    for(string st : words){
        bool ind=false;
        for(int j=1;j<=st.sz;j++)
            for(int i=0;i<=st.sz-j;i++){
                string nw=st.substr(i,j);
                if(get(root,nw)){
                    if(!ind){
                       cout << nw << "\n";
                       ind=true;
                    }
                }

            }
        for(int j=1;j<=st.sz;j++)
            for(int i=0;i<=st.sz-j;i++){
                string nw=st.substr(i,j);
                add(root,nw);
            }
    }
}
main(){
    int T=1;
    //cin >> T;
    while(T--){
        solve();
    }
}


#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ull unsigned ll
#define pb push_back
#define eb emplace_back
#define INF 1e9
#define sz size()
struct trie{
    trie *children[10];
    int End=0;
    trie(){
        for(auto &u: children)
            u=nullptr;
    }
};
void add(trie *root,string &st){
    trie *cur=root;
    for(char c: st){
        int indx=c-'0';
        if(cur->children[indx]==nullptr)
            cur->children[indx]=new trie;
        cur=cur->children[indx];
    }
    cur->End++;
}
bool IsGood(trie *root,string &st){
    trie *cur=root;
    for(char c: st){
        int indx=c-'0';
        if(cur->children[indx]==nullptr)
            cur->children[indx]=new trie;
        cur=cur->children[indx];
    }
    cur->End--;
    if(cur->End==0)
        true;
}
void solve(){
    int Q;
    cin >> Q;
    vector<string> words;
    trie *root=new trie;
    while(Q--){
        string st;
        cin >> st;
        words.pb(st);
        for(int j=1;j<=st.sz;j++)
            for(int i=0;i<=st.sz-j;i++){
                string nw=st.substr(i,j);
                add(root,nw);
            }
    }
    for(string st: u){
        vector<string> used;
        for(int j=1;j<=st.sz;j++)
            for(int i=0;i<=st.sz-j;i++){
                string nw=st.substr(i,j);
                used.pb(nw);
                if(IsGood(root,nw)){
                     cout << nw << "\n";
                      break;
                }
            }
        for(string nw :used){
            add(root,nw);
        }
    }
}
int main(){
    int T=1;
    //cin >> T;
    while(T--){
        solve();
    }
}


#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ull unsigned ll
#define pb push_back
#define eb emplace_back
#define INF 1e9
#define sz size()
using namespace std;
map<string,int> mp;
vector<string> words;
void answer(string &st){
     for(int j=1;j<=st.sz;j++)
            for(int i=0;i<=st.sz-j;i++){
                string nw=st.substr(i,j);
                if(mp[nw]==1){
                    cout << nw;
                    return;
                }
            }
    cout << -1;
}
void solve(){
    int Q;
    cin >> Q;
    while(Q--){
        string st;
        cin >> st;
        words.pb(st);
        set<string> s;
        for(int i=0;i<st.sz;i++)
            for(int j=1;j<=st.sz-i;j++){
                  int len=s.sz;
                  string nw=st.substr(i,j);
                  s.insert(nw);
                  if(len==s.sz)
                      continue;
                  mp[nw]++;
            }
    }
    for(string st: words){
        answer(st);
        cout << "\n";
    }
}
int main(){
    int T=1;
    //cin >> T;
    while(T--){
        solve();
    }
}


#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 5e5 + 5;

int n;
string s[maxn];
map<string,int> mp;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

  cin>>n;
  for (int x=0; x<n; x++) {
    cin>>s[x];
    int len = 9;
    for (int i=0; i<len; i++) {
      string cur = "";
      for (int j=i; j<len; j++) {
        cur += s[x][j];
        if (mp.find(cur) == mp.end() || x == mp[cur]) {
          mp[cur] = x;
        } else {
          mp[cur] = -1;
        }
      }
    }
  }

  for (int x=0; x<n; x++) {
    string ans;
    int len = 9;
    for (int i=0; i<len; i++) {
      int mxlen = 10;
      string cur = "";
      for (int j=i; j<len; j++) {
        cur += s[x][j];
        if (mp[cur] != -1) {
          int curlen = j-i+1;
          if (curlen < mxlen) {
            mxlen = curlen;
            ans = cur;
          }
        }
      }
    }
    cout<<ans<<'\n';
  }

  return 0;
}


#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 5e5 + 5;

int n;
string s[maxn];
map<string,int> mp;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

  cin>>n;
  for (int x=0; x<n; x++) {
    cin>>s[x];
    int len = 9;
    for (int i=0; i<len; i++) {
      string cur = "";
      for (int j=i; j<len; j++) {
        cur += s[x][j];
        if (mp.find(cur) == mp.end() || x == mp[cur]) {
          mp[cur] = x;
        } else {
          mp[cur] = -1;
        }
      }
    }
  }

  for (int x=0; x<n; x++) {
    string ans; int mxlen = 10;
    int len = 9;
    for (int i=0; i<len; i++) {
      string cur = "";
      for (int j=i; j<len; j++) {
        cur += s[x][j];
        if (mp[cur] != -1) {
          int curlen = j-i+1;
          if (curlen < mxlen) {
            mxlen = curlen;
            ans = cur;
          }
        }
      }
    }
    cout<<ans<<'\n';
  }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
map <pair <long long, long long>, long long> mp;
long long n, i, o, t, mn, d, sz, x, y, z, p;
string s[70010], ans;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (i = 0; i < n;i++)
    {
        cin >> s[i];
        for (o = 0; o < s[i].size(); o++)
        {
            d = sz = 0;
            for (t = o; t < s[i].size(); t++)
            {
                ++sz;
                d *= 10;
                d += s[i][t] - '0';
                if (mp[{d, sz}] == 0) mp[{d, sz}] = i + 1;
                else if (mp[{d, sz}] == i + 1) continue;
                else mp[{d, sz}] = -1;
            }
        }
    }
    for (i = 0; i < n; i++)
    {
        mn = 1e18;
        x = 0;
        for (o = 0; o < s[i].size(); o++)
        {
            d = sz = 0;
            for (t = o; t < s[i].size(); t++)
            {
                ++sz;
                d *= 10;
                d += s[i][t] - '0';
                if (mp[{d, sz}] == i + 1)
                {
                    if (sz < mn)
                    {
                        mn = sz;
                        x = sz;
                        p= d;
                    }
                }
            }
        }
        z = 0;
        y = p;
        //cout << mn << ' ' << x << '\n';
        do {
            z++;
            y /= 10;
        } while(y);
        x -= z;
        //cout << z << ' ';
        while(x--) {
            cout << '0';
        }
        cout << p << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
map <string, long long> mp;
long long n, i, o, t, mn;
string s[70010], d, ans;
int main()
{
    cin >> n;
    for (i = 0; i < n;i++)
    {
        cin >> s[i];
        for (o = 0; o < s[i].size(); o++)
        {
            d = "";
            for (t = o; t < s[i].size(); t++)
            {
                d += s[i][t];
                if (mp[d] == 0) mp[d] = i + 1;
                else if (mp[d] == i + 1) continue;
                else mp[d] = -1;
            }
        }
    }
    for (i = 0; i < n; i++)
    {
        ans = "";
        mn = 1e18;
        for (o = 0; o < s[i].size(); o++)
        {
            d = "";
            for (t = o; t < s[i].size(); t++)
            {
                d += s[i][t];
                if (mp[d] == i + 1)
                {
                    if (d.size() < mn)
                    {
                        mn = d.size();
                        ans = d;
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
map <string, long long> mp;
long long n, i, o, t, mn;
string s[70010], d, ans;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (i = 0; i < n;i++)
    {
        cin >> s[i];
        for (o = 0; o < s[i].size(); o++)
        {
            d = "";
            for (t = o; t < s[i].size(); t++)
            {
                d += s[i][t];
                if (mp[d] == 0) mp[d] = i + 1;
                else if (mp[d] == i + 1) continue;
                else mp[d] = -1;
            }
        }
    }
    for (i = 0; i < n; i++)
    {
        ans = "";
        mn = 1e18;
        for (o = 0; o < s[i].size(); o++)
        {
            d = "";
            for (t = o; t < s[i].size(); t++)
            {
                d += s[i][t];
                if (mp[d] == i + 1)
                {
                    if (d.size() < mn)
                    {
                        mn = d.size();
                        ans = d;
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
map <string, long long> mp, MapFl;
long long n, i, o, t, mx;
string s[70010], d, ans;
int main()
{
    cin >> n;
    for (i = 0; i < n; i++)
    {
        cin >> s[i];
        for (o = 0; o < s[i].size(); o++)
        {
            d = "";
            for (t = o; t < s[i].size(); t++)
            {
                d += s[i][t];
                if (MapFl[d] == 1) continue;
                MapFl[d] = 1;
                mp[d]++;
            }
        }
        for (o = 0; o < s[i].size(); o++)
        {
            d = "";
            for (t = o; t < s[i].size(); t++)
            {
                d += s[i][t];
                MapFl[d] = 0;
            }
        }
    }

    for (i = 0; i < n; i++)
    {
        mx = 1e18;
        ans = "";
        for (o = 0; o < s[i].size(); o++)
        {
            d = "";
            for (t = o; t < s[i].size(); t++)
            {
                d += s[i][t];
                if (mp[d] == 1)
                {
                    if (mx > d.size())
                    {
                        mx = d.size();
                        ans = d;
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;
int n;
map < string, int > mp;
string s[70100];

int main()
{
    cin >> n;
    getchar();
    for(int i=0; i<n; i++)
    {
        char c;
        while((c = getchar()) != '\n')  s[i]+=c;
        for(int j=0; j<9; j++)
        {
            string temp = "";
            for(int k = j; k<s[i].size(); k++)
            {
                temp+=s[i][k];
                mp[temp]++;
            }
        }
    }
    for(int i=0; i<n; i++)
    {
        string Ans = s[i];
        for(int j=0; j<9; j++)
        {
            string temp = "";
            for(int k = j; k<s[i].size(); k++)
            {
                temp+=s[i][k];
                mp[temp]--;
            }
        }
        for(int j=0; j<9; j++)
        {
            string temp = "";
            int Min = 10;
            for(int k = j; k<s[i].size(); k++)
            {
                temp+=s[i][k];
                if(mp[temp] == 0 && temp.size() < Min)
                {
                    Min = temp.size();
                    Ans = temp;
                }
            }
        }
        for(int j=0; j<9; j++)
        {
            string temp = "";
            for(int k = j; k<s[i].size(); k++)
            {
                temp+=s[i][k];
                mp[temp]++;
            }
        }
        for(int j=0;j<Ans.size();j++)  putchar(Ans[j]);
        printf("\n");
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;
int n;
string s[70100];

struct Node
{
    struct Node *children[11];
    int c;
};

struct Node *initilaize()
{

    struct Node *pNode = new struct Node;

    pNode->c = 0;

    for(int i=0; i<11; i++)
        pNode->children[i] = NULL;

    return pNode;
};

void Insert(struct Node *root, string s)
{
    struct Node *pNode = root;

    for(int i=0; i<s.size(); i++)
    {
        int idx = s[i] - '0';
        if(pNode->children[idx] == NULL)  pNode->children[idx] = initilaize();
        pNode = pNode->children[idx];
        pNode->c++;
    }
}

string GetAns(int i , int j , struct Node *root){

    struct Node *pNode = root;
    string Ans = "";
    while(j < s[i].size()){
        int idx = s[i][j] - '0';
        pNode = pNode->children[idx];
        Ans+=s[i][j];
        if(pNode->c == 1)   return Ans;
        j++;
    }
    return "Null";
}

int main()
{
    struct Node *Root = initilaize();
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> s[i];
        for(int j=0;j<s[i].size();j++){
            Insert(Root , s[i].substr(j , s[i].size() - j));
        }
    }
    for(int i=0;i<n;i++){
        int Min = 1e2;
        string Ans = "";
        for(int j = 0;j<9;j++){
            string Res = GetAns(i , j , Root);
            if(Res != "Null" && Res.size() < Min){
                Min = Res.size();
                Ans = Res;
            }
        }
        cout << Ans << '\n';
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;
int n;
string s[70100];

struct Node
{
    struct Node *children[11];
    int c;
};

struct Node *initilaize()
{

    struct Node *pNode = new struct Node;

    pNode->c = 0;

    for(int i=0; i<11; i++)
        pNode->children[i] = NULL;

    return pNode;
};

void Insert(struct Node *root, string s)
{
    struct Node *pNode = root;

    for(int i=0; i<s.size(); i++)
    {
        int idx = s[i] - '0';
        if(pNode->children[idx] == NULL)  pNode->children[idx] = initilaize();
        pNode = pNode->children[idx];
        pNode->c++;
    }
}

void Remove(struct Node *root , string s){
    struct Node *pNode = root;
    for(int i=0; i<s.size(); i++)
    {
        int idx = s[i] - '0';
        if(pNode->children[idx] == NULL)  pNode->children[idx] = initilaize();
        pNode = pNode->children[idx];
        pNode->c--;
    }

}

string GetAns(int i , int j , struct Node *root){

    struct Node *pNode = root;
    string Ans = "";
    while(j < s[i].size()){
        int idx = s[i][j] - '0';
        pNode = pNode->children[idx];
        Ans+=s[i][j];
        if(pNode->c == 0)   return Ans;
        j++;
    }
    return "Null";
}

int main()
{
    struct Node *Root = initilaize();
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> s[i];
        for(int j=0;j<s[i].size();j++){
            Insert(Root , s[i].substr(j , s[i].size() - j));
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<s[i].size();j++)
            Remove(Root , s[i].substr(j , s[i].size() - j));
        int Min = 1e2;
        string Ans = "";
        for(int j = 0;j<9;j++){
            string Res = GetAns(i , j , Root);
            if(Res != "Null" && Res.size() < Min){
                Min = Res.size();
                Ans = Res;
            }
        }
        cout << Ans << '\n';
        for(int j=0;j<s[i].size();j++){
            Insert(Root , s[i].substr(j , s[i].size() - j));
        }
    }
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;
multiset < string > st;
multiset < string >::iterator it;
vector < string > v;
vector < string > v2;

int main()
{
    long long n,i,j,k,p;  cin>>n;
    string K,s="";
    for(i=0;i<n;i++)
    {
        cin>>K;
        v.push_back(K);
        for(p=1;p<=9;p++)
        {
            for(j=0;j<10-p;j++)
            {
                for(k=j;k<p+j;k++)
                {
                    s+=K[k];
                }
                st.insert(s);
                s="";
            }
        }
    }
    s="";
    for(i=0;i<n;i++)
    {
        K=v[i];
        for(p=1;p<=9;p++)
        {
            for(j=0;j<10-p;j++)
            {
                for(k=j;k<p+j;k++)
                {
                    s+=K[k];
                }
                it=st.find(s);
                st.erase(it);
                v2.push_back(s);
                s="";
            }
        }
        s="";
        for(p=1;p<=9;p++)
        {
            for(j=0;j<10-p;j++)
            {
                for(k=j;k<p+j;k++)
                {
                    s+=K[k];
                }
                it=st.find(s);
                if(it==st.end())
                {
                    cout<<s<<endl;
                    break;
                }
                s="";
            }
            if(j<10-p)
                break;
        }
        s="";
        for(j=0;j<v2.size();j++)
            st.insert(v2[j]);
        v2.clear();
    }
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>

using namespace std;
multiset < string > st;
multiset < string >::iterator it;
vector < string > v;

int main()
{
    long long n,i,j,k,p;  cin>>n;
    string K,s="";
    for(i=0;i<n;i++)
    {
        cin>>K;
        v.push_back(K);
        for(p=1;p<=9;p++)
        {
            for(j=0;j<10-p;j++)
            {
                for(k=j;k<p+j;k++)
                {
                    s+=K[k];
                }
                st.insert(s);
                s="";
            }
        }
    }
    s="";
    for(i=0;i<n;i++)
    {
        K=v[i];
        for(p=1;p<=9;p++)
        {
            for(j=0;j<10-p;j++)
            {
                for(k=j;k<p+j;k++)
                {
                    s+=K[k];
                }
                it=st.find(s);
                st.erase(it);
                s="";
            }
        }
        s="";
        for(p=1;p<=9;p++)
        {
            for(j=0;j<10-p;j++)
            {
                for(k=j;k<p+j;k++)
                {
                    s+=K[k];
                }
                it=st.find(s);
                if(it==st.end())
                {
                    cout<<s<<endl;
                    break;
                }
                s="";
            }
            if(j<10-p)
                break;
        }
        s="";
        for(p=1;p<=9;p++)
        {
            for(j=0;j<10-p;j++)
            {
                for(k=j;k<p+j;k++)
                {
                    s+=K[k];
                }
                st.insert(s);
                s="";
            }
        }
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;
int n;
map < string, int > mp;
string s[70100];

int main()
{
    cin >> n;
    for(int i=0; i<n; i++)
    {
        cin >> s[i];
        for(int j=0; j<9; j++)
        {
            string temp = "";
            for(int k = j; k<s[i].size(); k++)
            {
                temp+=s[i][k];
                mp[temp]++;
            }
        }
    }
    for(int i=0; i<n; i++)
    {
        string Ans = s[i];
        for(int j=0; j<9; j++)
        {
            string temp = "";
            for(int k = j; k<s[i].size(); k++)
            {
                temp+=s[i][k];
                mp[temp]--;
            }
        }
        for(int j=0; j<9; j++)
        {
            string temp = "";
            int Min = 10;
            for(int k = j; k<s[i].size(); k++)
            {
                temp+=s[i][k];
                if(mp[temp] == 0 && temp.size() < Min)
                {
                    Min = temp.size();
                    Ans = temp;
                }
            }
        }
        for(int j=0; j<9; j++)
        {
            string temp = "";
            for(int k = j; k<s[i].size(); k++)
            {
                temp+=s[i][k];
                mp[temp]++;
            }
        }
        cout << Ans << '\n';
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>

using namespace std;
int n;
map < string, int > mp;
string s[70100];

int main()
{
    cin >> n;
    fflush(stdin);
    for(int i=0; i<n; i++)
    {
        char c;
        while((c = getchar()) != '\n')  s[i]+=c;
        for(int j=0; j<9; j++)
        {
            string temp = "";
            for(int k = j; k<s[i].size(); k++)
            {
                temp+=s[i][k];
                mp[temp]++;
            }
        }
    }
    for(int i=0; i<n; i++)
    {
        string Ans = s[i];
        for(int j=0; j<9; j++)
        {
            string temp = "";
            for(int k = j; k<s[i].size(); k++)
            {
                temp+=s[i][k];
                mp[temp]--;
            }
        }
        for(int j=0; j<9; j++)
        {
            string temp = "";
            int Min = 10;
            for(int k = j; k<s[i].size(); k++)
            {
                temp+=s[i][k];
                if(mp[temp] == 0 && temp.size() < Min)
                {
                    Min = temp.size();
                    Ans = temp;
                }
            }
        }
        for(int j=0; j<9; j++)
        {
            string temp = "";
            for(int k = j; k<s[i].size(); k++)
            {
                temp+=s[i][k];
                mp[temp]++;
            }
        }
        for(int j=0;j<Ans.size();j++)  putchar(Ans[j]);
        printf("\n");
    }
    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,A,B) for(int i=A;i<=B;i++)
#define mod 1000000007
#define v1d vector<int>
#define v2d vector<vector<int>>
#define vip vector<pair<int,int> >
#define v1s vector<string>
#define v2s vector<vector<string> >
#define vsp vector<pair<string,string> >
#define endl "\n"

string cmp(string s1,string s2){
    /*int n1=0;
    for(auto i:s1){
        n1= n1*10+(i-'0');
    }
    int n2=0;
    for(auto i:s2){
        n2= n2*10+(i-'0');
    }
    if(n1==n2){
        if(s1.length()>s2.length())
            return s2;
        return s1;
    }
    if(n1>n2)return s2;
    return s1;*/

    if(s1.length()==s2.length()){
        if(s1>s2)return s2;
        else return s1;
    }
    if(s1.length()>s2.length())return s2;
    return s1;
}

int32_t main(){
    IOS;
    int n;cin>>n;
    map<string,int> u;
    v1s v(n);
    map<string,int> r;
    for(int i=0;i<n;i++){
        cin>>v[i];
        set<string> myset;
        for(int k=0;k<=8;k++){
            string s="";
            for(int j=k;j<=8;j++){
                s+= v[i][j];
                myset.insert(s);
            }
        }
        for(auto s:myset){
            if(r.count(s)){
                continue;
            }
            if(u.count(s)){
                r[s]++;
                u.erase(s);
            }
            else{
                u[s]++;
            }
        }
    }
    for(int i=0;i<n;i++){
        string p="9999999999999999";
        for(int k=0;k<=8;k++){
            string s="";
            for(int j=k;j<=8;j++){
                s+= v[i][j];
                if(u.count(s)){
                    u.erase(s);
                    p= cmp(p,s);
                }
            }
        }
        cout<<p<<endl;
    }

    return 0;
}


#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,A,B) for(int i=A;i<=B;i++)
#define mod 1000000007
#define v1d vector<int>
#define v2d vector<vector<int>>
#define vip vector<pair<int,int> >
#define v1s vector<string>
#define v2s vector<vector<string> >
#define vsp vector<pair<string,string> >
#define endl "\n"

string cmp(string s1,string s2){
    int n1=0;
    for(auto i:s1){
        n1= n1*10+(i-'0');
    }
    int n2=0;
    for(auto i:s2){
        n2= n2*10+(i-'0');
    }
    if(n1==n2){
        if(s1.length()>s2.length())
            return s2;
        return s1;
    }
    if(n1>n2)return s2;
    return s1;

    if(s1.length()==s2.length()){
        if(s1>s2)return s2;
        else return s1;
    }
    if(s1.length()>s2.length())return s2;
    return s1;
}

int32_t main(){
    IOS;
    int n;cin>>n;
    map<string,int> u;
    v1s v(n);
    map<string,int> r;
    for(int i=0;i<n;i++){
        cin>>v[i];
        set<string> myset;
        for(int k=0;k<=8;k++){
            string s="";
            for(int j=k;j<=8;j++){
                s+= v[i][j];
                myset.insert(s);
            }
        }
        for(auto s:myset){
            if(r.count(s)){
                continue;
            }
            if(u.count(s)){
                r[s]++;
                u.erase(s);
            }
            else{
                u[s]++;
            }
        }
    }
    for(int i=0;i<n;i++){
        string p="9999999999999999";
        for(int k=0;k<=8;k++){
            string s="";
            for(int j=k;j<=8;j++){
                s+= v[i][j];
                if(u.count(s)){
                    u.erase(s);
                    p= cmp(p,s);
                }
            }
        }
        cout<<p<<endl;
    }

    return 0;
}


/*
for:
Hussien , Ayman , Emad
Abanob , George , Genawy
Ka8eem , Mosta7il , Stawro
ICPC DREAM
*/
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned ll
#define endl '\n'
#define mk make_pair
#define holla(x) cout << #x << " is " << x << endl;
const double PI = acos(-1.0);
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };
const int N = 7e4+154, M = 5000 + 5, mod = 998244353;
map<string, int>mp;
int main() {
	fast_in_out();
	//cout << fixed << setprecision(9);
	//kolo ray7 , ya 5raby
	int n; cin >> n;
	vector<string>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		for (int j = 0; j < 9; j++) {
			string str;
			for (int k = j; k < 9; k++) {
				str.push_back(v[i][k]);
				if (mp.find(str) == mp.end()) {
					mp[str] = i;
				}
				else if (mp[str] == i)continue;
				else mp[str] = -1;
			}
		}
	}
	for (auto e : mp) {
		if (e.second != -1)
			if (v[e.second].size() > e.first.size())
				v[e.second] = e.first;
	}
	for (auto e : v)
		cout << e << endl;
	return 0;

}


/*
for:
Hussien , Ayman , Emad
Abanob , George , Genawy
Ka8eem , Mosta7il , Stawro
ICPC DREAM
*/
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned ll
#define endl '\n'
#define mk make_pair
#define holla(x) cout << #x << " is " << x << endl;
const double PI = acos(-1.0);
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };
const int N = 7e4+154, M = 5000 + 5, mod = 998244353;
set<pair<int,string>>adj[N];
map<string, int>mp;
int main() {
	fast_in_out();
	//cout << fixed << setprecision(9);
	//kolo ray7 , ya 5raby
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		string str;
		cin >> str;
	//	cout << i << endl;
		for (int ii = 0; ii < str.size(); ii++) {
			string s="";
			for (int j = ii; j < str.size(); ++j) {
				s += str[j];
				//cout << s << endl;
				adj[i].emplace(s.size(), s);
				if(mp.find(s)!=mp.end()&&mp[s]!=i)
				{
					mp[s] = -1;
				}
				else {
					mp[s] = i;
				}
			}
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (auto e : adj[i]) {
			if (mp[e.second] == -1)continue;
			cout << e.second << endl;
			break;
		}
	}

	return 0;

}


/*
for:
Hussien , Ayman , Emad
Abanob , George , Genawy
Ka8eem , Mosta7il , Stawro
ICPC DREAM
*/
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned ll
#define endl '\n'
#define mk make_pair
#define holla(x) cout << #x << " is " << x << endl;
const double PI = acos(-1.0);
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };
const int N = 7e4+154, M = 5000 + 5, mod = 998244353;
map<string, int>mp;
int main() {
	fast_in_out();
	//cout << fixed << setprecision(9);
	//kolo ray7 , ya 5raby
	int n; cin >> n;
	vector<string>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		for (int j = 0; j < str.size(); j++) {
			string str;
			for (int k = j; k < str.size(); k++) {
				str += v[i][k];
				if (mp.find(str) == mp.end()) {
					mp[str] = i;
				}
				else if (mp[str] == i)continue;
				else mp[str] = -1;
			}
		}
	}
	for (auto e : mp) {
		if (e.second != -1)
			if (v[e.second].size() > e.first.size())
				v[e.second] = e.first;
	}
	for (auto e : v)
		cout << e << endl;
	return 0;

}


/*
for:
Hussien , Ayman , Emad
Abanob , George , Genawy
Ka8eem , Mosta7il , Stawro
ICPC DREAM
*/
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned ll
#define endl '\n'
#define mk make_pair
#define holla(x) cout << #x << " is " << x << endl;
const double PI = acos(-1.0);
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };
const int N = 7e4+154, M = 5000 + 5, mod = 998244353;
map<string, int>mp;
int main() {
	fast_in_out();
	//cout << fixed << setprecision(9);
	//kolo ray7 , ya 5raby
	int n; cin >> n;
	vector<string>v(n);
	int sz = 9;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		for (int j = 0; j < sz; j++) {
			string str;
			for (int k = j; k < sz; k++) {
				str += v[i][k];
				if (mp.find(str) == mp.end()) {
					mp[str] = i;
				}
				else if (mp[str] == i)continue;
				else mp[str] = -1;
			}
		}
	}
	for (auto e : mp) {
		if (e.second != -1)
			if (v[e.second].size() > e.first.size())
				v[e.second] = e.first;
	}
	for (auto e : v)
		cout << e << endl;
	return 0;

}


/*
for:
Hussien , Ayman , Emad
Abanob , George , Genawy
Ka8eem , Mosta7il , Stawro
ICPC DREAM
*/
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned ll
#define endl '\n'
#define mk make_pair
#define holla(x) cout << #x << " is " << x << endl;
const double PI = acos(-1.0);
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };
const int N = 7e4+154, M = 5000 + 6, mod = 998244353;
map<string, int>mp;
int main() {
	fast_in_out();
	//cout << fixed << setprecision(9);
	//kolo ray7 , ya 5raby
	int n; cin >> n;
	vector<string>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		for (int j = 0; j < 9; j++) {
			string str;
			for (int k = j; k < 9; k++) {
				str += v[i][k];
				if (mp.find(str) == mp.end()) {
					mp[str] = i;
				}
				else if (mp[str] == i)continue;
				else mp[str] = -1;
			}
		}
	}
	for (auto e : mp) {
		if (e.second != -1)
			if (v[e.second].size() > e.first.size())
				v[e.second] = e.first;
	}
	for (auto e : v)
		cout << e << endl;
	return 0;

}


/*
for:
Hussien , Ayman , Emad
Abanob , George , Genawy
Ka8eem , Mosta7il , Stawro
ICPC DREAM
*/
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned ll
#define endl '\n'
#define mk make_pair
#define holla(x) cout << #x << " is " << x << endl;
const double PI = acos(-1.0);
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };
const int N = 7e4+154, M = 5000 + 5, mod = 998244353;
map<string, int>mp;
string v[N];
int main() {
	fast_in_out();
	//cout << fixed << setprecision(9);
	//kolo ray7 , ya 5raby
	int n; cin >> n;
	int sz = 9;
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		for (int j = 0; j < sz; ++j) {
			string str;
			for (int k = j; k < sz; ++k) {
				str += v[i][k];
				if (mp.find(str) == mp.end()) {
					mp[str] = i;
				}
				else if (mp[str] == i)continue;
				else mp[str] = -1;
			}
		}
	}
	for (auto e : mp) {
		if (e.second != -1)
			if (v[e.second].size() > e.first.size())
				v[e.second] = e.first;
	}
	for (auto e : v)
		cout << e << endl;
	return 0;

}


/*
for:
Hussien , Ayman , Emad
Abanob , George , Genawy
Ka8eem , Mosta7il , Stawro
ICPC DREAM
*/
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned ll
#define endl '\n'
#define mk make_pair
#define holla(x) cout << #x << " is " << x << endl;
const double PI = acos(-1.0);
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };
const int N = 7e4+154, M = 5000 + 5, mod = 998244353;
map<string, int>mp;
int main() {
	fast_in_out();
	//cout << fixed << setprecision(9);
	//kolo ray7 , ya 5raby
	int n; cin >> n;
	vector<string>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		for (int j = 0; j < 9; j++) {
			string str;
			for (int k = j; k < 9; k++) {
				str += v[i][k];
				if (mp.find(str) == mp.end()) {
					mp[str] = i;
				}
				else if (mp[str] == i)continue;
				else mp[str] = -1;
			}
		}
	}
	for (auto e : mp) {
		if (e.second != -1)
			if (v[e.second].size() > e.first.size())
				v[e.second] = e.first;
	}
	for (auto e : v)
		cout << e << endl;
	return 0;

}


/*
for:
Hussien , Ayman , Emad
Abanob , George , Genawy
Ka8eem , Mosta7il , Stawro
ICPC DREAM
*/
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned ll
#define endl '\n'
#define mk make_pair
#define holla(x) cout << #x << " is " << x << endl;
const double PI = acos(-1.0);
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };
const int N = 7e4+154, M = 5000 + 5, mod = 998244353;
map<string, int>mp;
int main() {
	fast_in_out();
	//cout << fixed << setprecision(9);
	//kolo ray7 , ya 5raby
	int n; cin >> n;
	vector<string>v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		for (int j = 0; j < 9; ++j) {
			string str;
			for (int k = j; k < 9; ++k) {
				str += v[i][k];
				if (mp.find(str) == mp.end()) {
					mp[str] = i;
				}
				else if (mp[str] == i)continue;
				else mp[str] = -1;
			}
		}
	}
	for (auto e : mp) {
		if (e.second != -1)
			if (v[e.second].size() > e.first.size())
				v[e.second] = e.first;
	}
	for (auto e : v)
		cout << e << endl;
	return 0;

}


/*
for:
Hussien , Ayman , Emad
Abanob , George , Genawy
Ka8eem , Mosta7il , Stawro
ICPC DREAM
*/
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define ld long double
#define ull unsigned ll
#define endl '\n'
#define mk make_pair
#define holla(x) cout << #x << " is " << x << endl;
const double PI = acos(-1.0);
void fast_in_out() {
	std::ios_base::sync_with_stdio(NULL);
	cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

}
int dx[] = { 0,0,-1,1,-1,1,-1,1,0 };
int dy[] = { -1,1,0,0,-1,-1,1,1,0 };
const int N = 7e4+154, M = 5000 + 5, mod = 998244353;
map<string, int>mp;
int main() {
	fast_in_out();
	//cout << fixed << setprecision(9);
	//kolo ray7 , ya 5raby
	int n; cin >> n;
	vector<string>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		for (int j = 0; j < v[i].size(); j++) {
			string str;
			for (int k = j; k < v[i].size(); k++) {
				str += v[i][k];
				if (mp.find(str) == mp.end()) {
					mp[str] = i;
				}
				else if (mp[str] == i)continue;
				else mp[str] = -1;
			}
		}
	}
	for (auto e : mp) {
		if (e.second != -1)
			if (v[e.second].size() > e.first.size())
				v[e.second] = e.first;
	}
	for (auto e : v)
		cout << e << endl;
	return 0;

}


#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <cmath>
#include <stdio.h>

//#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define ld double
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pld pair <ld, ld>
#define pii pair <ll, ll>

using namespace std;

//using namespace __gnu_pbds;
/*
typedef
tree<
  pii,
  null_type,
  less<pii>,
  rb_tree_tag,
  // This policy updates nodes' metadata for order statistics.
  tree_order_statistics_node_update>
set_t;*/

const ll INF = 1e18 + 7;
const int N = 1e4 * 7 + 10;
const int M = 1e6;
const ld EPS = 1 / 1e16;
const double PI = 3.1415926535897;
const ll HESH = 73;
const ll MOD = 998244353;

string s[N], ans[N];
map <string, int> m, used[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(0);

    int n;
    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> s[i];

    for (int k = 0; k < n; k++) {
        for (int j = 1; j < s[k].size(); j++)
            for (int i = 0; i <= s[k].size() - j; i++) {
                //cout << s[k].substr(i, j) << "\n";
                used[k][s[k].substr(i, j)]++, m[s[k].substr(i, j)]++;
            }

    }

    for (int t = 0; t < n; t++) {
        int k = 1;
        for (int j = 1; k && j < s[t].size(); j++)
            for (int i = 0; k && i <= s[t].size() - j; i++)
                if (m[s[t].substr(i, j)] - used[t][s[t].substr(i, j)] == 0)
                    ans[t] = s[t].substr(i, j), k = 0;
    }

    for (int i = 0; i < n; i++)
        cout << ans[i] << "\n";
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <cmath>
#include <stdio.h>

//#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define ld double
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pld pair <ld, ld>
#define pii pair <ll, ll>

using namespace std;

//using namespace __gnu_pbds;
/*
typedef
tree<
  pii,
  null_type,
  less<pii>,
  rb_tree_tag,
  // This policy updates nodes' metadata for order statistics.
  tree_order_statistics_node_update>
set_t;*/

const ll INF = 1e18 + 7;
const int N = 1e6 * 2 + 10;
const int M = 1e6;
const ld EPS = 1 / 1e16;
const double PI = 3.1415926535897;
const ll HESH = 73;
const ll MOD = 998244353;

string s[N], ans[N];
map <string, int> m, used[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(0);

    int n;
    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> s[i];

    for (int k = 0; k < n; k++) {
        for (int j = 1; j < s[k].size(); j++)
            for (int i = 0; i <= s[k].size() - j; i++) {
                //cout << s[k].substr(i, j) << "\n";
                used[k][s[k].substr(i, j)]++, m[s[k].substr(i, j)]++;
            }

    }

    for (int t = 0; t < n; t++) {
        int k = 1;
        for (int j = 1; k && j < s[t].size(); j++)
            for (int i = 0; k && i <= s[t].size() - j; i++)
                if (m[s[t].substr(i, j)] - used[t][s[t].substr(i, j)] == 0)
                    ans[t] = s[t].substr(i, j), k = 0;
    }

    for (int i = 0; i < n; i++)
        cout << ans[i] << "\n";
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <cmath>
#include <stdio.h>

//#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define ld double
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pld pair <ld, ld>
#define pii pair <ll, ll>

using namespace std;

//using namespace __gnu_pbds;
/*
typedef
tree<
  pii,
  null_type,
  less<pii>,
  rb_tree_tag,
  // This policy updates nodes' metadata for order statistics.
  tree_order_statistics_node_update>
set_t;*/

const ll INF = 1e18 + 7;
const int N = 1e4 * 7 + 10;
const int M = 1e6;
const ld EPS = 1 / 1e16;
const double PI = 3.1415926535897;
const ll HESH = 73;
const ll MOD = 998244353;

string s[N], ans[N];
map <string, int> m, used[N];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(0);

    int n;
    cin >> n;

    for (int i = 0; i < n; i++)
        cin >> s[i];

    for (int k = 0; k < n; k++) {
        for (int j = 1; j <= s[k].size(); j++)
            for (int i = 0; i <= s[k].size() - j; i++) {
              //  cout << s[k].substr(i, j) << "\n";
                used[k][s[k].substr(i, j)]++, m[s[k].substr(i, j)]++;
            }
    }

    for (int t = 0; t < n; t++) {
        int k = 1;
        for (int j = 1; k && j <= s[t].size(); j++)
            for (int i = 0; k && i <= s[t].size() - j; i++)
                if (m[s[t].substr(i, j)] - used[t][s[t].substr(i, j)] == 0)
                    ans[t] = s[t].substr(i, j), k = 0;
    }

    for (int i = 0; i < n; i++)
        cout << ans[i] << "\n";
    return 0;
}

/*
3
112345678
123456789
234567899
*/


#pragma GCC optimize("03")
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef int ll;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> pi;
string st[70005];
map<string,ll> mp,mp1;
// void update(string st,ll val)
// {
// 	string st1="";
// 	ll m=st.length();
// 	for(ll j=0;j<m;j++)
// 	{
// 		st1="";
// 		for(ll k=j;k<m;k++)
// 		{
// 			st1+=st[k];
// 			mp[st1]+=val;
// 		}

// 	}
// }
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m,len,mn;
	string st1,ans;
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		cin>>st[i];
		m=st[i].length();
		for(ll j=0;j<m;j++)
		{
			st1="";
			for(ll k=j;k<m;k++)
			{
				st1+=st[i][k];
				mp[st1]+=1;
			}
		}
	}
	for(ll i=0;i<n;i++)
	{
		m=st[i].length();
		mn=100;
		ans="";
		mp1.clear();
		for(ll j=0;j<m;j++)
		{
			st1="";
			for(ll k=j;k<m;k++)
			{
				st1+=st[i][k];
				mp1[st1]+=1;
			}
		}
		for(ll j=0;j<m;j++)
		{
			st1="";
			for(ll k=j;k<m;k++)
			{
				st1+=st[i][k];
				if(mp1[st1] >= mp[st1])
				{
					len=k-j+1;
					if(mn > len)
					{
						mn=len;
						ans=st1;
					}
				}
			}
		}
		// update(st[i],1);
		cout<<ans<<endl;
		// ans+=mn;
	}
	//cout<<ans<<endl;
	return 0;
}


#pragma GCC optimize("03")
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef int ll;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> pi;
string st[70005];
map<string,ll> mp;
void update(string st,ll val)
{
	string st1="";
	ll m=st.length();
	for(ll j=0;j<m;j++)
	{
		st1="";
		for(ll k=j;k<m;k++)
		{
			st1+=st[k];
			mp[st1]+=val;
		}

	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m,len,mn;
	string st1,ans;
	cin>>n;
	for(ll i=0;i<n;i++)
	{
		cin>>st[i];
		m=st[i].length();
		for(ll j=0;j<m;j++)
		{
			st1="";
			for(ll k=j;k<m;k++)
			{
				st1+=st[i][k];
				mp[st1]+=1;
			}
		}
	}
	for(ll i=0;i<n;i++)
	{
		m=st[i].length();
		mn=100;
		ans="";
		update(st[i],-1);
		for(ll j=0;j<m;j++)
		{
			st1="";
			for(ll k=j;k<m;k++)
			{
				st1+=st[i][k];
				if(mp[st1] == 0)
				{
					len=k-j+1;
					if(mn > len)
					{
						mn=len;
						ans=st1;
					}
				}
			}
		}
		update(st[i],1);
		cout<<ans<<endl;
		// ans+=mn;
	}
	//cout<<ans<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define se second
#define pb push_back
#define io ios_base::sync_with_stdio(false),cin.tie(NULL)
#define MAXN 70009
map<int,vector<string>> m;
string s[MAXN];
map<string,int> mp;
signed main()
{
    io;
    int n,i,j,k;cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>s[i];
        map<string,int> q;
        for(j=1;j<10;j++)
        {
            for(k=0;k<10-j;k++)
            {
                string r=s[i].substr(k,j);
                if(q.find(r)==q.end())
                {m[i].pb(r);mp[r]++;q[r]++;}
            }
        }
    }
    for(i=0;i<n;i++)
    {
        for(auto s:m[i])
        {
            if(mp[s]==1)
            {cout<<s<<"\n";
            break;}
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define se second
#define pb push_back
#define io ios_base::sync_with_stdio(false),cin.tie(NULL)
#define MAXN 70009
map<int,set<string>> m;
string s[MAXN];
map<string,int> mp;
signed main()
{
    io;
    int n,i,j,k;cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>s[i];
        for(j=1;j<10;j++)
        {
            for(k=0;k<10-j;k++)
            {
                string r=s[i].substr(k,j);
                if(m[i].find(r)==m[i].end())
                {m[i].insert(r);mp[r]++;}
            }
        }
    }
    for(i=0;i<n;i++)
    {
        for(auto s:m[i])
        {
            if(mp[s]==1)
            {cout<<s<<"\n";
            break;}
        }
    }
}


/********** Raaghav Raaj (cf: raaghavraaj, cc: mothercoder27) *************/
#include<bits/stdc++.h>
using namespace std;
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false);
#pragma optimize("-O3")

// #ifndef ONLINE_JUDGE
// #include "../Codechef/trace.h"
// #else
// #define trace(args...)
// #endif

// #define int long long
#define double long double
#define vi vector<int>
#define vc vector<char>
#define pi pair<int, int>
#define pii pair<pi,int>
#define rep(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define sp " "
#define endl '\n'
#define all(v) v.begin(), v.end()
#define debug(data) for(auto it: data) cout<<it<<sp;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

const int sz = 998244353;

int gcd(int n, int m) {
	return __gcd(n, m);
}

int power(int a, int b) {
	a %= sz;
	int res = 1;
	while (b) {
		if (b & 1) res = (res * a) % sz;
		a = (a * a) % sz;
		b >>= 1;
	}
	return res;
}

int modInverse(int a) { //sz must be prime
	return power(a, sz - 2);
}
map<string, int> cnt;
void solve() {
	int n; cin >> n;
	vector<string> a(n);
	rep(i, 0, n) {
		cin >> a[i];
		string s = a[i];
		set<string> st;
		rep(len, 1, 10) {
			rep(j, 0, 10 - len) {
				st.insert(s.substr(j, len));
			}
		}
		for (auto &str : st) {
			cnt[str]++;
		}
	}
	rep(i, 0, n) {
		bool f = 0;
		rep(len, 1, 10) {
			rep(j, 0, 10 - len) {
				if (cnt[a[i].substr(j, len)] == 1) {
					cout << a[i].substr(j, len) << endl;
					f = 1; break;
				}
			}
			if (f) break;
		}
	}
}

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("tracefile.txt", "w", stderr);
#endif
	fast;
	int T = 1;
	// cin >> T;
	rep(i, 1, T + 1) {
		// cout << "Case #" << i << ": ";
		solve();
	}
}


/********** Raaghav Raaj (cf: raaghavraaj, cc: mothercoder27) *************/
#include<bits/stdc++.h>
using namespace std;
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false);
#pragma optimize("-O3")

// #ifndef ONLINE_JUDGE
// #include "../Codechef/trace.h"
// #else
// #define trace(args...)
// #endif

#define int long long
#define double long double
#define vi vector<int>
#define vc vector<char>
#define pi pair<int, int>
#define pii pair<pi,int>
#define rep(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define sp " "
#define endl '\n'
#define all(v) v.begin(), v.end()
#define debug(data) for(auto it: data) cout<<it<<sp;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

const int sz = 998244353;

int gcd(int n, int m) {
	return __gcd(n, m);
}

int power(int a, int b) {
	a %= sz;
	int res = 1;
	while (b) {
		if (b & 1) res = (res * a) % sz;
		a = (a * a) % sz;
		b >>= 1;
	}
	return res;
}

int modInverse(int a) { //sz must be prime
	return power(a, sz - 2);
}
map<string, int> cnt;
void solve() {
	int n; cin >> n;
	vector<string> a(n);
	vector<set<pair<int, string> > > st(n);
	rep(i, 0, n) {
		cin >> a[i];
		for (int len = 9; len >= 1; len--) {
			rep(j, 0, 9 - len + 1) {
				st[i].insert(make_pair(len, a[i].substr(j, len)));
			}
		}
		// cout << st[i].size() << endl; debug(st[i]); cout << endl;
		for (auto it : st[i]) cnt[it.S]++;
	}
	rep(i, 0, n) {
		// debug(st[i]); cout << endl;
		for (auto it : st[i]) {
			if (cnt[it.S] == 1) {
				cout << it.S << endl;
				break;
			}
		}
	}
}

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("tracefile.txt", "w", stderr);
#endif
	fast;
	int T = 1;
	// cin >> T;
	rep(i, 1, T + 1) {
		// cout << "Case #" << i << ": ";
		solve();
	}
}


/********** Raaghav Raaj (cf: raaghavraaj, cc: mothercoder27) *************/
#include<bits/stdc++.h>
using namespace std;
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false);
#pragma optimize("-O3")

// #ifndef ONLINE_JUDGE
// #include "../Codechef/trace.h"
// #else
// #define trace(args...)
// #endif

// #define int long long
#define double long double
#define vi vector<int>
#define vc vector<char>
#define pi pair<int, int>
#define pii pair<pi,int>
#define rep(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define sp " "
#define endl '\n'
#define all(v) v.begin(), v.end()
#define debug(data) for(auto it: data) cout<<it<<sp;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

const int sz = 998244353;

int gcd(int n, int m) {
	return __gcd(n, m);
}

int power(int a, int b) {
	a %= sz;
	int res = 1;
	while (b) {
		if (b & 1) res = (res * a) % sz;
		a = (a * a) % sz;
		b >>= 1;
	}
	return res;
}

int modInverse(int a) { //sz must be prime
	return power(a, sz - 2);
}
unordered_map<string, int> cnt;
void solve() {
	int n; cin >> n;
	vector<string> a(n);
	rep(i, 0, n) {
		cin >> a[i];
		string s = a[i];
		set<string> st;
		rep(len, 1, 10) {
			rep(j, 0, 10 - len) {
				st.insert(s.substr(j, len));
			}
		}
		for (auto &str : st) {
			cnt[str]++;
		}
	}
	rep(i, 0, n) {
		bool f = 0;
		rep(len, 1, 10) {
			rep(j, 0, 10 - len) {
				if (cnt[a[i].substr(j, len)] == 1) {
					cout << a[i].substr(j, len) << endl;
					f = 1; break;
				}
			}
			if (f) break;
		}
	}
}

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("tracefile.txt", "w", stderr);
#endif
	fast;
	int T = 1;
	// cin >> T;
	rep(i, 1, T + 1) {
		// cout << "Case #" << i << ": ";
		solve();
	}
}


/********** Raaghav Raaj (cf: raaghavraaj, cc: mothercoder27) *************/
#include<bits/stdc++.h>
using namespace std;
#define fast cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false);
#pragma optimize("-O3")

// #ifndef ONLINE_JUDGE
// #include "../Codechef/trace.h"
// #else
// #define trace(args...)
// #endif

// #define int long long
#define double long double
#define vi vector<int>
#define vc vector<char>
#define pi pair<int, int>
#define pii pair<pi,int>
#define rep(i,a,b) for(int i=a; i<b; i++)
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define sp " "
#define endl '\n'
#define all(v) v.begin(), v.end()
#define debug(data) for(auto it: data) cout<<it<<sp;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

const int sz = 998244353;

int gcd(int n, int m) {
	return __gcd(n, m);
}

int power(int a, int b) {
	a %= sz;
	int res = 1;
	while (b) {
		if (b & 1) res = (res * a) % sz;
		a = (a * a) % sz;
		b >>= 1;
	}
	return res;
}

int modInverse(int a) { //sz must be prime
	return power(a, sz - 2);
}
map<string, vi> cnt;
void solve() {
	int n; cin >> n;
	vector<string> a(n);
	vector<set<pair<int, int> > > st(n);
	rep(i, 0, n) {
		cin >> a[i];
		rep(len, 1, 10) {
			rep(j, 0, 10 - len) {
				st[i].insert(make_pair(len, j));
			}
		}
		// cout << st[i].size() << endl; debug(st[i]); cout << endl;
		for (auto it : st[i]) {
			if (cnt[a[i].substr(it.S, it.F)].size() == 0 || cnt[a[i].substr(it.S, it.F)].back() != i)cnt[a[i].substr(it.S, it.F)].PB(i);
			// cout << a[i].substr(it.S, it.F) << sp;
		}
		// cout << endl;
	}
	rep(i, 0, n) {
		// debug(st[i]); cout << endl;
		for (auto it : st[i]) {
			if (cnt[a[i].substr(it.S, it.F)].size() == 1) {
				cout << a[i].substr(it.S, it.F) << endl;
				break;
			}
		}
	}
}

int32_t main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("tracefile.txt", "w", stderr);
#endif
	fast;
	int T = 1;
	// cin >> T;
	rep(i, 1, T + 1) {
		// cout << "Case #" << i << ": ";
		solve();
	}
}


#include <bits/stdc++.h>
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x,y,z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define INF 1000000000
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pll>	vpll;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;

const ll MOD = 1000000000+7;

ll n;
vector<string> vs;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;
    vs.resize(n);
    unordered_map<string,ll> hash;
    for(ll k=0;k<n;k++)
    {
        cin>>vs[k];
        for(int i=0;i<9;i++)
        {
            for(int j=0;j<9-i;j++)
            {
                string temp = vs[k].substr(j,i+1);
                if(hash[temp])
                    hash[temp]++;
                else
                    hash[temp] = 1;
            }
        }
    }

    for(int k=0;k<n;k++)
    {
        for(int i=0;i<9;i++)
        {
            int flag = 0;
            for(int j=0;j<9-i;j++)
            {
                string temp = vs[k].substr(j,i+1);
                if(hash[temp] and hash[temp]-1==0)
                {
                    cout<<temp<<endl;
                    flag = 1;
                    break;
                }
            }
            if(flag) break;
        }
    }

    return 0;
}


#include <bits/stdc++.h>
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x,y,z) cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define INF 1000000000
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>	vi;
typedef vector<ll>	vl;
typedef vector<pii>	vpii;
typedef vector<pll>	vpll;
typedef vector<vi>	vvi;
typedef vector<vl>	vvl;

const ll MOD = 1000000000+7;

ll n;
vector<string> vs;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;
    vs.resize(n);
    unordered_map<string,ll> hash;
    for(ll k=0;k<n;k++)
    {
        cin>>vs[k];
        for(int i=0;i<9;i++)
        {
            for(int j=0;j<9-i;j++)
            {
                string temp = vs[k].substr(j,i+1);
                if(hash[temp])
                    hash[temp]++;
                else
                    hash[temp] = 1;
            }
        }
    }

    for(int k=0;k<n;k++)
    {
        for(int i=0;i<9;i++)
        {
            for(int j=0;j<9-i;j++)
            {
                string temp = vs[k].substr(j,i+1);
                hash[temp]--;
            }
        }

        for(int i=0;i<9;i++)
        {
            int flag = 0;
            for(int j=0;j<9-i;j++)
            {
                string temp = vs[k].substr(j,i+1);
                if(hash[temp]==0)
                {
                    cout<<temp<<endl;
                    flag = 1;
                    break;
                }
            }
            if(flag) break;
        }

        for(int i=0;i<9;i++)
        {
            for(int j=0;j<9-i;j++)
            {
                string temp = vs[k].substr(j,i+1);
                hash[temp]++;
            }
        }
    }

    return 0;
}


/*
  ______    _ _ ____       _   _            _   _           _ _______ _
 |  ____|  (_) |  _ \     | | | |          | \ | |         | |__   __(_)
 | |__ __ _ _| | |_) | ___| |_| |_ ___ _ __|  \| | _____  _| |_ | |   _ _ __ ___   ___
 |  __/ _` | | |  _ < / _ \ __| __/ _ \ '__| . ` |/ _ \ \/ / __|| |  | | '_ ` _ \ / _ \
 | | | (_| | | | |_) |  __/ |_| ||  __/ |  | |\  |  __/>  <| |_ | |  | | | | | | |  __/
 |_|  \__,_|_|_|____/ \___|\__|\__\___|_|  |_| \_|\___/_/\_\\__||_|  |_|_| |_| |_|\___|

*/
#include <bits/stdc++.h>
#define int long long
#define sz(x) (int)(x.size())
using namespace std;

class node{
   public:
      node* child[10];
      int cnt;
      node(){
         for(int i = 0; i < 10; i++)
            child[i] = NULL;
         cnt = 0;
      }
};

typedef node* nodeptr;

class TRIE{
   private:
      nodeptr root;

   public:

      TRIE(){
         root = new node();
      }

      void insert(string &s){
         int n = sz(s);
         nodeptr curr = root;
         for(int i = 0; i < n; i++){
            int next = s[i] - '0';
            if(curr->child[next] == NULL)
               curr->child[next] = new node();
            curr = curr->child[next];

         }
         curr->cnt++;
      }

      int getCount(string &s){
         nodeptr curr = root;
         for(int i = 0; i < sz(s); i++){
            int next = s[i] - '0';
            curr = curr->child[next];
         }
         return curr->cnt;
      }

};

set<string> f[70000];

int32_t main(){

	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

   int n;
   cin >> n;
   TRIE T;

   for(int i = 0; i < n; i++){
      string s;   cin >> s;
      for(int j = 0; j < sz(s); j++){
         string curr;
         for(int k = j; k < sz(s); k++){
            curr += s[k];
            f[i].insert(curr);
         }
      }
      for(string it : f[i])
         T.insert(it);
   }

   for(int i = 0; i < n; i++){
      string ans = "99999999999";
      for(string it : f[i]){
         int cnt = T.getCount(it);
         if(cnt == 1 && (sz(ans) > sz(it)))
            ans = it;
      }
      cout << ans << '\n';
   }

	return 0;
}


/*
  ______    _ _ ____       _   _            _   _           _ _______ _
 |  ____|  (_) |  _ \     | | | |          | \ | |         | |__   __(_)
 | |__ __ _ _| | |_) | ___| |_| |_ ___ _ __|  \| | _____  _| |_ | |   _ _ __ ___   ___
 |  __/ _` | | |  _ < / _ \ __| __/ _ \ '__| . ` |/ _ \ \/ / __|| |  | | '_ ` _ \ / _ \
 | | | (_| | | | |_) |  __/ |_| ||  __/ |  | |\  |  __/>  <| |_ | |  | | | | | | |  __/
 |_|  \__,_|_|_|____/ \___|\__|\__\___|_|  |_| \_|\___/_/\_\\__||_|  |_|_| |_| |_|\___|

*/
#include <bits/stdc++.h>
#define int long long
#define sz(x) (int)(x.size())
using namespace std;

class node{
   public:
      node* child[10];
      int cnt;
      node(){
         for(int i = 0; i < 10; i++)
            child[i] = NULL;
         cnt = 0;
      }
};

typedef node* nodeptr;

class TRIE{
   private:
      nodeptr root;

   public:

      TRIE(){
         root = new node();
      }

      void insert(string &s){
         int n = sz(s);
         nodeptr curr = root;
         for(int i = 0; i < n; i++){
            int next = s[i] - '0';
            if(curr->child[next] == NULL)
               curr->child[next] = new node();
            curr = curr->child[next];

         }
         curr->cnt++;
      }

      int getCount(string &s){
         nodeptr curr = root;
         for(int i = 0; i < sz(s); i++){
            int next = s[i] - '0';
            if(curr->child[next] == NULL)
               return 0;
            curr = curr->child[next];
         }
         return curr->cnt;
      }

};

set<string> f[70000];

int32_t main(){

	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

   int n;
   cin >> n;
   TRIE T;

   for(int i = 0; i < n; i++){
      string s;   cin >> s;
      for(int j = 0; j < sz(s); j++){
         string curr;
         for(int k = j; k < sz(s); k++){
            curr += s[k];
            f[i].insert(curr);
         }
      }
      for(string it : f[i])
         T.insert(it);
   }

   for(int i = 0; i < n; i++){
      string ans = "99999999999";
      for(string it : f[i]){
         int cnt = T.getCount(it);
         if(cnt == 1 && (sz(ans) > sz(it)))
            ans = it;
      }
      cout << ans << '\n';
   }

	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;
int main(){
	int n;
	cin>>n;
	map<string,int> mp;
	string a[n+1];
	for(int k=1;k<=n;k++){
		cin>>a[k];
		for(int i=1;i<=9;i++){
			for(int j=0;j<=9-i;j++){
				string s1=a[k].substr(j,i);
				if(mp[s1]==0)
				   mp[s1]=k;
				else{
					if(mp[s1]!=k)
					   mp[s1]=-1;
				}
			}
		}
	}
	for(int k=1;k<=n;k++){
		for(int i=1;i<=9;i++){
			ll ind1=0;
			for(int j=0;j<=9-i;j++){
				string s1=a[k].substr(j,i);
				if(mp[s1]!=-1){
				   cout<<s1<<"\n";
				   ind1=1;
				   break;
			    }
			}
			if(ind1==1)
			   break;
		}
	}
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;
int main(){
	ll a,b;
	cin>>a>>b;
	cout<<a+b;
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
using namespace std;
struct trienode{
	trienode *children[10];
	ll count=0;
	trienode(){
		for(auto &child:children){
			child=nullptr;
		}
	}
};
void insert(trienode *root,string s){
	trienode *curnode=root;
	for(char c:s){
		ll index=c-'0';
		if(curnode->children[index]==nullptr){
			curnode->children[index]=new trienode;
		}
		curnode=curnode->children[index];
	}
	curnode->count++;
}
ll search(trienode *root,string s){
	trienode *curnode=root;
	for(char c:s){
		ll index=c-'0';
		if(curnode->children[index]==nullptr){
			return -1;
		}
		curnode=curnode->children[index];
	}
	curnode->count--;
	return curnode->count;
}
int main(){
	int n;
	cin>>n;
	string a[n+1];
	trienode *root=new trienode;
	for(int k=1;k<=n;k++){
		cin>>a[k];
		for(int i=1;i<=9;i++){
			for(int j=0;j<=9-i;j++){
				string s1=a[k].substr(j,i);
				insert(root,s1);
			}
		}
	}
    for(int k=1;k<=n;k++){
	    ll ind=0;
		for(int i=1;i<=9;i++){

			for(int j=0;j<=9-i;j++){
				string s1=a[k].substr(j,i);
				ll ans=search(root,s1);
				if(ans==0&&ind==0){
					cout<<s1<<"\n";
					ind=1;
				}
			}
		}
		for(int i=1;i<=9;i++){
			for(int j=0;j<=9-i;j++){
				string s1=a[k].substr(j,i);
				insert(root,s1);
			}
		}

	}
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lll long long

using namespace std;
const int NR= 1e5 + 100 ,oo = 1e9 + 10, MOD = 1e9 + 7;
const long double pi = 2*acos(0.0);

int n ;
map < string , int > mpp;
string dq ;
string  s ;
vector < string > sol ( NR ) ;
int main ()     {
    int i, l , j ;
    cin >> n ;
    for ( i = 1 ; i <= n ; ++ i )   {
        cin >> s ;
        for ( j = 1 ; j <= 9 ; ++ j )   {
            for ( l = 0 ; l + j <= 9 ; ++ l )    {
                dq = s.substr(l , j );
                if ( mpp [ dq ] > 0 && mpp [ dq ] != i )  {
                    mpp [ dq ] = -1 ;
                }
                if ( mpp [ dq ] == 0 )  {
                    mpp [ dq ] = i ;
                }
            }
        }
    }
    map < string , int > :: iterator it ;
    for ( it = mpp.begin() ; it != mpp.end() ; ++ it )   {
        if ( (*it).second == -1 )   continue ;
        dq = (*it).first ;
        if (  sol [ (*it).second ].empty() || ( int ) ( dq.size() ) < sol [ (*it).second ].size() )
            sol [ (*it).second ] = dq ;
    }

    for ( i = 1 ; i <= n ; ++ i )
        cout << sol [ i ] << '\n' ;

    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lll long long

using namespace std;
const int NR= 1e5 + 100 ,oo = 1e9 + 10, MOD = 1e9 + 7;
const long double pi = 2*acos(0.0);

int n ;
map < deque < char > , int > mpp;
deque < char > dq ;
string  s ;
vector < deque < char > > sol ( NR ) ;
int main ()     {
    int i, l , j ;
    cin >> n ;
    for ( i = 1 ; i <= n ; ++ i )   {
        cin >> s ;
        for ( j = 1 ; j <= 9 ; ++ j )   {
            dq.clear() ;
            for ( l = 0 ; l < j ; ++ l )    {
                dq.pb( s [ l ] ) ;
            }
            if ( mpp [ dq ] >  0 )  {
                mpp [ dq ] = -1 ;
            }
            if ( mpp [ dq ] == 0 )  {
                mpp [ dq ] = i ;
            }
            for ( l = j ; l < 9 ; ++ l )    {
                dq.pop_front() ;
                dq.pb( s [ l ] ) ;
                if ( mpp [ dq ] > 0 && mpp [ dq ] != i )  {
                    mpp [ dq ] = -1 ;
                }
                if ( mpp [ dq ] == 0 )  {
                    mpp [ dq ] = i ;
                }
            }
        }
    }
    map < deque < char > , int > :: iterator it ;
    for ( it = mpp.begin() ; it != mpp.end() ; ++ it )   {
        if ( (*it).second == -1 )   continue ;
        dq = (*it).first ;
        if (  sol [ (*it).second ].empty() || ( int ) ( dq.size() ) < sol [ (*it).second ].size() )
            sol [ (*it).second ] = dq ;
    }

   for ( i = 1 ; i <= n ; ++ i , cout << '\n' )
      for ( j = 0 ; j < sol [ i ].size() ; ++ j )
          cout << sol [ i ][ j ] ;

    return 0;
}


#include"bits/stdc++.h"
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
typedef long long int ll;
const ll N=1e6+2,inf=1e9+7;
void _run();
void no(){cout<<"-1\n",exit(0);}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	_run();
	return 0;
}
string rs[N];
void _run()
{
    int n;cin>>n;string s[n+1];
    for(int i=1;i<=n;i++)cin>>s[i];
    vector<pair<pair<int,string>,int> >vec;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<9;j++)
        {
            string cur="";
            for(int k=j;k<9;k++)
            {
                cur+=s[i][k];
                vec.pb(mp(mp((int)cur.size(),cur),i));
            }
        }
    }
    sort(vec.begin(),vec.end());
    map<int,int>M;
    string prv="";
    set<pair<string,int> >st;
    for(auto x:vec)
    {
        if(x.fs.sc!=prv)
        {
            if(st.size()==1)
            {
                auto it=*st.begin();
                if(rs[it.sc].size()==0)rs[it.sc]=it.fs;
            }
            st.clear();
            st.insert(mp(x.fs.sc,x.sc));
            prv=x.fs.sc;
        }
        else st.insert(mp(x.fs.sc,x.sc));
    }
    if(st.size()==1)
    {
        auto it=*st.begin();
        if(rs[it.sc].size()==0)rs[it.sc]=it.fs;
    }
    for(int i=1;i<=n;i++)cout<<rs[i]<<"\n";
}


#include"bits/stdc++.h"
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
typedef long long int ll;
const ll N=1e6+2,inf=1e9+7;
void _run();
void no(){cout<<"-1\n",exit(0);}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	_run();
	return 0;
}
string rs[N];
void _run()
{
    int n;cin>>n;string s[n+1];
    for(int i=1;i<=n;i++)cin>>s[i];
    vector<pair<string,int> >vec;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<9;j++)
        {
            string cur="";
            for(int k=j;k<9;k++)
            {
                cur+=s[i][k];
                vec.pb(mp(cur,i));
            }
        }
    }
    sort(vec.begin(),vec.end());
    map<string,int>M;
    for(auto x:vec)
    {
        if(M.find(x.fs)==M.end()&&rs[x.sc].size()==0)
            rs[x.sc]=x.fs,M[x.fs]=1;
    }
    for(int i=1;i<=n;i++)cout<<rs[i]<<"\n";
}


#include"bits/stdc++.h"
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
typedef long long int ll;
const ll N=1e6+2,inf=1e9+7;
void _run();
void no(){cout<<"-1\n",exit(0);}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	_run();
	return 0;
}
string rs[N];
void _run()
{
    int n;cin>>n;string s[n+1];
    for(int i=1;i<=n;i++)cin>>s[i];
    vector<pair<pair<int,string>,int> >vec;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<9;j++)
        {
            string cur="";
            for(int k=j;k<9;k++)
            {
                cur+=s[i][k];
                vec.pb(mp(mp((int)cur.size(),cur),i));
            }
        }
    }
    sort(vec.begin(),vec.end());
    map<int,int>M;
    string prv="";
    set<pair<string,int> >st;
    for(auto x:vec)
    {
        if(x.fs.sc!=prv)
        {
            if(st.size()==1)
            {
                auto it=*st.begin();
                if(rs[it.sc].size()==0)rs[it.sc]=it.fs;
            }
            st.clear();
            st.insert(mp(x.fs.sc,x.sc));
            prv=x.fs.sc;
        }
        else st.insert(mp(x.fs.sc,x.sc));
    }
    for(int i=1;i<=n;i++)cout<<rs[i]<<"\n";
}


#include"bits/stdc++.h"
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
typedef long long int ll;
const ll N=1e6+2,inf=1e9+7;
void _run();
void no(){cout<<"-1\n",exit(0);}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	_run();
	return 0;
}
string rs[N];
void _run()
{
    int n;cin>>n;string s[n+1];
    for(int i=1;i<=n;i++)cin>>s[i];
    vector<pair<string,int> >vec;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<9;j++)
        {
            string cur="";
            for(int k=j;k<9;k++)
            {
                cur+=s[i][k];
                vec.pb(mp(cur,i));
            }
        }
    }
    sort(vec.begin(),vec.end());
    map<int,int>M;
    string prv="";
    set<pair<string,int> >st;
    for(auto x:vec)
    {
        if(x.fs!=prv)
        {
            if(st.size()==1)
            {
                auto it=*st.begin();
                if(rs[it.sc].size()==0)rs[it.sc]=it.fs;
            }
            st.clear();
            st.insert(x);
            prv=x.fs;
        }
        else st.insert(x);
    }
    for(int i=1;i<=n;i++)cout<<rs[i]<<"\n";
}


#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
using namespace std;

//map<string,vector<ll>>mp;
//khud kiya without any hint
string s[70005];
ll n,nn;

int main()
{
	cin>>nn;
	ll i,j,k,l;
	n=9;
	map<string,int >mp;
	for(i=1;i<=nn;i++)
		cin>>s[i];

	for(i=1;i<=nn;i++)
	{
		string alp="";

		for(j=1;j<=n;j++)
		{
			for(k=0;k<=n-j;k++)
			{	alp="";
				for(l=k;l<k+j&&l<n;l++)
					alp+=s[i][l];
				if(mp.find(alp)==mp.end()||mp[alp]==i)
				mp[alp]=i;
				else
				mp[alp]=-1;
			}
		}
	}
	bool flag=0;

	for(i=1;i<=nn;i++)
	{
		string alp="";
		flag=0;
		for(j=1;j<=n;j++)
		{
			for(k=0;k<=n-j;k++)
			{	alp="";
				for(l=k;l<k+j&&l<n;l++)
				{
					alp+=s[i][l];

					if(mp[alp]>0)
					{
						flag=1;
						cout<<alp<<"\n";
						break;
					}
				}
				if(flag)
					break;

			}
			if(flag)
					break;
		}
	}

}


#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
using namespace std;

//map<string,vector<ll>>mp;
string s[70005];
ll n,nn;

bool cmp(string x,string y)
{
	return x.size()<y.size();
}

int main()
{
	cin>>nn;
	ll i,j,k,l;
	n=10;
	map<string,vector<ll>,cmp >mp;
	for(i=1;i<=n;i++)
		cin>>s[i];

	for(i=1;i<=nn;i++)
	{
		string alp="";

		for(j=1;j<=n;j++)
		{
			for(k=0;k<=n-i;k++)
			{	alp="";
				for(l=k;l<k+j&&l<n;l++)
					alp+=s[i][l];
				mp[alp].pb(i);
			}
		}
	}
	map<ll,string>ans;
	//ll cnt=1;
	for(auto it:mp)
	{
		if(ans.size()==nn)
			break;
		if(mp[it.first].size()==1&&ans.find(mp[it.first])==ans.end())
		{
			ans[mp[it.first][0]]=it.first;
		}
		else
			continue;
	}

	for(auto it : ans)
		cout<<ans.second<<"\n";

}


#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
using namespace std;

//map<string,vector<ll>>mp;
//khud kiya without any hint
string s[70005];
ll n,nn;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>nn;
	ll i,j,k,l;
	n=9;
	map<string,int >mp;
	for(i=1;i<=nn;i++)
		cin>>s[i];

	for(i=1;i<=nn;i++)
	{
		string alp="";

		for(j=0;j<n;j++)
		{
			alp="";
			for(k=j;k<n;k++)
			{
				alp+=s[i][k];

				if(mp.find(alp)==mp.end()||mp[alp]==i)
					mp[alp]=i;
				else
					mp[alp]=-1;
			}
		}
	}
	bool flag=0;

	for(i=1;i<=nn;i++)
	{
		string alp="",ans;
		ll maxi=12;

		//flag=0;
		for(j=0;j<n;j++)
		{
			alp="";
			for(k=j;k<n;k++)
			{
				alp+=s[i][k];

				if(mp[alp]!=-1&&k-j+1<maxi)
				{
					maxi=k-j+1;
					ans=alp;
				}
			}

		}
		cout<<ans<<"\n";
	}

}


#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
using namespace std;

//map<string,vector<ll>>mp;
//khud kiya without any hint
string s[70005];
ll n,nn;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>nn;
	ll i,j,k,l;
	n=9;
	map<string,int >mp;
	for(i=1;i<=nn;i++)
		cin>>s[i];

	for(i=1;i<=nn;i++)
	{
		string alp="";

		for(j=1;j<=n;j++)
		{
			for(k=0;k<=n-j;k++)
			{	alp="";
				for(l=k;l<k+j&&l<n;l++)
					alp+=s[i][l];
				if(mp.find(alp)==mp.end()||mp[alp]==i)
				mp[alp]=i;
				else
				mp[alp]=-1;
			}
		}
	}
	bool flag=0;

	for(i=1;i<=nn;i++)
	{
		string alp="";
		flag=0;
		for(j=1;j<=n;j++)
		{
			for(k=0;k<=n-j;k++)
			{	alp="";
				for(l=k;l<k+j&&l<n;l++)
				{
					alp+=s[i][l];

					if(mp[alp]>0)
					{
						flag=1;
						cout<<alp<<"\n";
						break;
					}
				}
				if(flag)
					break;

			}
			if(flag)
					break;
		}
	}

}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpll vector<pll>
#define vpii vector<pii>
#define umap unordered_map
#define uset unordered_set
#define PQ priority_queue

#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a) printa(a,0,a.size())
#define print2d(a,r,c) for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define fbo find_by_order
#define ook order_of_key
#define MP make_pair
#define UB upper_bound
#define LB lower_bound
#define SQ(x) ((x)*(x))
#define issq(x) (((ll)(sqrt((x))))*((ll)(sqrt((x))))==(x))
#define F first
#define S second
#define mem(a,x) memset(a,x,sizeof(a))
#define inf 1e18
#define E 2.71828182845904523536
#define gamma 0.5772156649
#define nl "\n"
#define lg(r,n) (int)(log2(n)/log2(r))
#define pf printf
#define sf scanf
#define sf1(a)                scanf("%d",&a)
#define sf2(a,b)              scanf("%d %d",&a,&b)
#define sf3(a,b,c)            scanf("%d %d %d",&a,&b,&c)
#define pf1(a)                printf("%d\n",a);
#define pf2(a,b)              printf("%d %d\n",a,b)
#define pf3(a,b,c)            printf("%d %d %d\n",a,b,c)
#define sf1ll(a)              scanf("%lld",&a)
#define sf2ll(a,b)            scanf("%I64d %I64d",&a,&b)
#define sf3ll(a,b,c)          scanf("%I64d %I64d %I64d",&a,&b,&c)
#define pf1ll(a)              printf("%lld\n",a);
#define pf2ll(a,b)            printf("%I64d %I64d\n",a,b)
#define pf3ll(a,b,c)          printf("%I64d %I64d %I64d\n",a,b,c)
#define _ccase printf("Case %lld: ",++cs)
#define _case cout<<"Case "<<++cs<<": "
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }

#define asche cerr<<"Ekhane asche\n";
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<ll>())
#define all(v) v.begin(),v.end()
#define mnv(v) *min_element(v.begin(),v.end())
#define mxv(v) *max_element(v.begin(),v.end())
#define toint(a) atoi(a.c_str())
#define BeatMeScanf ios_base::sync_with_stdio(false)
#define valid(tx,ty) (tx>=0&&tx<n&&ty>=0&&ty<m)
#define one(x) __builtin_popcount(x)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define stree l=(n<<1),r=l+1,mid=b+(e-b)/2
#define fout(x) fixed<<setprecision(x)
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
inline void yes(){cout<<"YES\n";exit(0);}
inline void no(){cout<<"NO\n";exit(0);}
template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//ll dx[]={1,0,-1,0,1,-1,-1,1};
//ll dy[]={0,1,0,-1,1,1,-1,-1};
//random_device rd;
//mt19937 rnd(rd());
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); deb(_it, args); }
void deb(istream_iterator<string> it) {}
template<typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    deb(++it, args...);
}

const int mod=1e9+7;
const int N=70100;
const ld eps=1e-9;
const ld PI=acos(-1.0);
//ll gcd(ll a,ll b){while(b){ll x=a%b;a=b;b=x;}return a;}
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}

umap<string,int>mp;
vector<string>v[N];
string s[N];
int main()
{
    BeatMeScanf;
    int i,j,k,n;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>s[i];
        for(j=0;j<9;j++){
            string nw="";
            for(k=j;k<9;k++){
                nw+=s[i][k];
                int p=mp[nw];
                if(p==0||p==i) v[i].eb(nw),mp[nw]=i;
                else mp[nw]=1e9;
            }
        }
        sort(all(v[i]),[](string &a,string &b){return a.size()<b.size();});
    }
    for(i=1;i<=n;i++){
        for(auto x:v[i]){
            if(mp[x]==i){
                cout<<x<<nl;
                break;
            }
        }
    }

    return 0;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpll vector<pll>
#define vpii vector<pii>
#define umap unordered_map
#define uset unordered_set
#define PQ priority_queue

#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a) printa(a,0,a.size())
#define print2d(a,r,c) for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define fbo find_by_order
#define ook order_of_key
#define MP make_pair
#define UB upper_bound
#define LB lower_bound
#define SQ(x) ((x)*(x))
#define issq(x) (((ll)(sqrt((x))))*((ll)(sqrt((x))))==(x))
#define F first
#define S second
#define mem(a,x) memset(a,x,sizeof(a))
#define inf 1e18
#define E 2.71828182845904523536
#define gamma 0.5772156649
#define nl "\n"
#define lg(r,n) (int)(log2(n)/log2(r))
#define pf printf
#define sf scanf
#define sf1(a)                scanf("%d",&a)
#define sf2(a,b)              scanf("%d %d",&a,&b)
#define sf3(a,b,c)            scanf("%d %d %d",&a,&b,&c)
#define pf1(a)                printf("%d\n",a);
#define pf2(a,b)              printf("%d %d\n",a,b)
#define pf3(a,b,c)            printf("%d %d %d\n",a,b,c)
#define sf1ll(a)              scanf("%lld",&a)
#define sf2ll(a,b)            scanf("%I64d %I64d",&a,&b)
#define sf3ll(a,b,c)          scanf("%I64d %I64d %I64d",&a,&b,&c)
#define pf1ll(a)              printf("%lld\n",a);
#define pf2ll(a,b)            printf("%I64d %I64d\n",a,b)
#define pf3ll(a,b,c)          printf("%I64d %I64d %I64d\n",a,b,c)
#define _ccase printf("Case %lld: ",++cs)
#define _case cout<<"Case "<<++cs<<": "
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }

#define asche cerr<<"Ekhane asche\n";
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<ll>())
#define all(v) v.begin(),v.end()
#define mnv(v) *min_element(v.begin(),v.end())
#define mxv(v) *max_element(v.begin(),v.end())
#define toint(a) atoi(a.c_str())
#define BeatMeScanf ios_base::sync_with_stdio(false)
#define valid(tx,ty) (tx>=0&&tx<n&&ty>=0&&ty<m)
#define one(x) __builtin_popcount(x)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define stree l=(n<<1),r=l+1,mid=b+(e-b)/2
#define fout(x) fixed<<setprecision(x)
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
inline void yes(){cout<<"YES\n";exit(0);}
inline void no(){cout<<"NO\n";exit(0);}
template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//ll dx[]={1,0,-1,0,1,-1,-1,1};
//ll dy[]={0,1,0,-1,1,1,-1,-1};
//random_device rd;
//mt19937 rnd(rd());
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); deb(_it, args); }
void deb(istream_iterator<string> it) {}
template<typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    deb(++it, args...);
}

const int mod=1e9+7;
const int N=70100;
const ld eps=1e-9;
const ld PI=acos(-1.0);
//ll gcd(ll a,ll b){while(b){ll x=a%b;a=b;b=x;}return a;}
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}

map<string,int>mp,m[N];
vector<string>v[N];
string s[N];
int main()
{
    BeatMeScanf;
    int i,j,k,n;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>s[i];
        for(j=0;j<9;j++){
            string nw="";
            for(k=j;k<9;k++){
                nw+=s[i][k];
                mp[nw]++;
                v[i].eb(nw);
                m[i][nw]++;
            }
        }
        sort(all(v[i]),[](string &a,string &b){return a.size()<b.size();});
    }
    for(i=1;i<=n;i++){
        for(auto x:v[i]){
            if(mp[x]-m[i][x]==0){
                cout<<x<<nl;
                break;
            }
        }
    }

    return 0;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpll vector<pll>
#define vpii vector<pii>
#define umap unordered_map
#define uset unordered_set
#define PQ priority_queue

#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a) printa(a,0,a.size())
#define print2d(a,r,c) for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb push_back
#define eb emplace_back
#define mt make_tuple
#define fbo find_by_order
#define ook order_of_key
#define MP make_pair
#define UB upper_bound
#define LB lower_bound
#define SQ(x) ((x)*(x))
#define issq(x) (((ll)(sqrt((x))))*((ll)(sqrt((x))))==(x))
#define F first
#define S second
#define mem(a,x) memset(a,x,sizeof(a))
#define inf 1e18
#define E 2.71828182845904523536
#define gamma 0.5772156649
#define nl "\n"
#define lg(r,n) (int)(log2(n)/log2(r))
#define pf printf
#define sf scanf
#define sf1(a)                scanf("%d",&a)
#define sf2(a,b)              scanf("%d %d",&a,&b)
#define sf3(a,b,c)            scanf("%d %d %d",&a,&b,&c)
#define pf1(a)                printf("%d\n",a);
#define pf2(a,b)              printf("%d %d\n",a,b)
#define pf3(a,b,c)            printf("%d %d %d\n",a,b,c)
#define sf1ll(a)              scanf("%lld",&a)
#define sf2ll(a,b)            scanf("%I64d %I64d",&a,&b)
#define sf3ll(a,b,c)          scanf("%I64d %I64d %I64d",&a,&b,&c)
#define pf1ll(a)              printf("%lld\n",a);
#define pf2ll(a,b)            printf("%I64d %I64d\n",a,b)
#define pf3ll(a,b,c)          printf("%I64d %I64d %I64d\n",a,b,c)
#define _ccase printf("Case %lld: ",++cs)
#define _case cout<<"Case "<<++cs<<": "
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }

#define asche cerr<<"Ekhane asche\n";
#define rev(v) reverse(v.begin(),v.end())
#define srt(v) sort(v.begin(),v.end())
#define grtsrt(v) sort(v.begin(),v.end(),greater<ll>())
#define all(v) v.begin(),v.end()
#define mnv(v) *min_element(v.begin(),v.end())
#define mxv(v) *max_element(v.begin(),v.end())
#define toint(a) atoi(a.c_str())
#define BeatMeScanf ios_base::sync_with_stdio(false)
#define valid(tx,ty) (tx>=0&&tx<n&&ty>=0&&ty<m)
#define one(x) __builtin_popcount(x)
#define Unique(v) v.erase(unique(all(v)),v.end())
#define stree l=(n<<1),r=l+1,mid=b+(e-b)/2
#define fout(x) fixed<<setprecision(x)
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
inline void yes(){cout<<"YES\n";exit(0);}
inline void no(){cout<<"NO\n";exit(0);}
template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//ll dx[]={1,0,-1,0,1,-1,-1,1};
//ll dy[]={0,1,0,-1,1,1,-1,-1};
//random_device rd;
//mt19937 rnd(rd());
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); deb(_it, args); }
void deb(istream_iterator<string> it) {}
template<typename T, typename... Args>
void deb(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    deb(++it, args...);
}

const int mod=1e9+7;
const int N=70100;
const ld eps=1e-9;
const ld PI=acos(-1.0);
//ll gcd(ll a,ll b){while(b){ll x=a%b;a=b;b=x;}return a;}
//ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//ll qpow(ll n,ll k) {ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}

map<string,int>mp;
vector<string>v[N];
string s[N];
int main()
{
    BeatMeScanf;
    int i,j,k,n;
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>s[i];
        for(j=0;j<9;j++){
            string nw="";
            for(k=j;k<9;k++){
                nw+=s[i][k];
                int p=mp[nw];
                if(p==0||p==i) v[i].eb(nw),mp[nw]=i;
                else mp[nw]=1e9;
            }
        }
        sort(all(v[i]),[](string &a,string &b){return a.size()<b.size();});
    }
    for(i=1;i<=n;i++){
        for(auto x:v[i]){
            if(mp[x]==i){
                cout<<x<<nl;
                break;
            }
        }
    }

    return 0;
}