#include <bits/stdc++.h>
using namespace std;
int n,idx;
string ans,s;
vector<string>v(70005);
unordered_map<long long,long long>mp,mpp;
long long h(string s){
    long long p = s.size() - 1, res = 0, b = 1;
    for(int i=0; i<p; i++)
        b*=10;
    for(auto i : s)
        res += b * (i - 47), b/=10;
    return res;
}
int main()
{
    ios::sync_with_stdio(0);
    cin>> n;
    for(int i = 0; i < n; i++){
        cin >> v[i];
        mpp.clear();
        for(int j =0; j<v[i].size(); j++){
            s = "";
            s += v[i][j];
            if(!mpp.count(h(s))){
                mp[h(s)]++;
                mpp[h(s)]++;
            }
            for(int k = j + 1; k<v[i].size(); k++){
                s += v[i][k];
                if(!mpp.count(h(s))){
                    mp[h(s)]++;
                    mpp[h(s)]++;
                }
            }
        }
    }
    for(int i = 0; i < n; i++){
        ans = "0000000000000000";
        for(int j =0; j<v[i].size(); j++){
            s = "";
            s += v[i][j];
            if(mp[h(s)] == 1){
                if(s.size() < ans.size())
                    ans = s;
            }
            for(int k = j + 1; k<v[i].size(); k++){
                s += v[i][k];
                if(mp[h(s)] == 1){
                    if(s.size() < ans.size())
                        ans = s;
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

struct Node{
	int n[10];
	int end;
	Node(){
		end=0;
		memset(n,-1,sizeof(n));
	}
};

int n ;
string z;
char y[70001][11];
vector<Node> node;
void add(string &s){
	int cur = 0;
	for(int i = 0 ; i < s.size(); i++){
		if(node[cur].n[s[i]-'0']==-1){
			node.push_back(Node());
			node[cur].n[s[i]-'0'] = node.size()-1;
		}
		cur = node[cur].n[s[i]-'0'];
	}

	node[cur].end++;
}
string r;
int search(string &s){
	int cur = 0;
	for(int i = 0 ;i < s.size() ; i++){
		if(node[cur].n[s[i]-'0']==-1){
			return 0;
		}
		cur = node[cur].n[s[i]-'0'];
	}
	return node[cur].end;
}
int main() {
	int n ;
	cin >> n;
	set<string> aa;
	node.push_back(Node());
	for(int i = 0 ; i < n ; i++){
		scanf("%s", y[i]);
		int x=0;
		for(int k = 0 ; k < 9 ; k++){
			z=y[i][k];
			aa.insert(z);

			for(int j = k+1 ; j < 9 ; j++){
				z+=y[i][j];
				aa.insert(z);
			}
		}
		for (set<string>::iterator it = aa.begin(); it != aa.end(); ++it){
			string aaa=*it;
			add(aaa);
		}
		aa.clear();
	}
	for(int i = 0 ; i < n ; i++){
		string ans=y[i];
		for(int k = 0 ; k < 9 ; k++){
			z=y[i][k];
			if(search(z)==1){
				if(z.size()<=ans.size())ans=z;
			}
			for(int j = k+1 ; j < 9 ; j++){
				z+=y[i][j];
				if(search(z)==1){
					if(z.size()<=ans.size())ans=z;
				}
			}
			if(search(z)==1){
				if(z.size()<=ans.size())ans=z;
			}
		}
		printf("%s\n" ,ans.c_str());

	}
	return 0;
}


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

typedef long long ll;
unordered_map<string , int> x,r;
string z;
char y[70001][11];
int main() {
	int n ;
	cin >> n;
	for(int i = 0 ; i < n ; i++){
		scanf("%s", y[i]);
		for(int k = 0 ; k < 9 ; k++){
			z=y[i][k];
			if(!r[z])r[z]++;
			for(int j = k+1 ; j < 9 ; j++){
				z+=y[i][j];
				if(!r[z])r[z]++;
			}
		}
		for (unordered_map<string ,int>::iterator it = r.begin(); it != r.end(); ++it){
			x[it->first]+=it->second;
		}
		r.clear();
	}
	for(int i = 0 ; i < n ; i++){
		string ans=y[i];
		for(int k = 0 ; k < 9 ; k++){
			z=y[i][k];
			if(x[z]==1){
				if(z.size()<=ans.size())ans=z;
			}
			for(int j = k+1 ; j < 9 ; j++){
				z+=y[i][j];
				if(x[z]==1){
					if(z.size()<=ans.size())ans=z;
				}
			}
			if(x[z]==1){
				if(z.size()<=ans.size())ans=z;
			}
		}
		printf("%s\n" ,ans.c_str());

	}

	return 0;
}


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

typedef long long ll;
unordered_map<string , int> x,r;
string z;
char y[70001][11];
int main() {
	int n ;
	cin >> n;
	for(int i = 0 ; i < n ; i++){
		scanf("%s", y[i]);
		for(int k = 0 ; k < 9 ; k++){
			z=y[i][k];
			r[z]++;
			for(int j = k+1 ; j < 9 ; j++){
				z+=y[i][j];
				if(!r[z])r[z]++;
			}
		}
		for (unordered_map<string ,int>::iterator it = r.begin(); it != r.end(); ++it){
			x[it->first]+=it->second;
		}
		r.clear();
	}
	for(int i = 0 ; i < n ; i++){
		string ans=y[i];
		for(int k = 0 ; k < 9 ; k++){
			z=y[i][k];
			if(x[z]==1){
				if(z.size()<=ans.size())ans=z;
			}
			for(int j = k+1 ; j < 9 ; j++){
				z+=y[i][j];
				if(x[z]==1){
					if(z.size()<=ans.size())ans=z;
				}
			}
			if(x[z]==1){
				if(z.size()<=ans.size())ans=z;
			}
		}
		printf("%s\n" ,ans.c_str());

	}

	return 0;
}


#include <cmath>
#include <cassert>
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <set>
#include <fstream>

bool gl(char c)
{
    return c == 'a' || c == 'o' || c == 'u' || c == 'e' || c == 'i';
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    int n;
    std::cin >> n;
    std::vector<std::string> num;
    std::vector<std::set<std::string>> sub;
    for (int i = 0; i < n; ++i)
    {
        std::string s;
        std::set<std::string> set;
        std::cin >> s;
        for (int j = 0; j < s.length(); ++j)
        {
            for (int k = 0; k < s.length() - j; ++k)
            {
                set.insert(s.substr(j, k + 1));
            }
        }
        sub.push_back(set);
        num.push_back(s);
    }
    std::multiset<std::string> superset;
    for (int i = 0; i < n; ++i)
    {
        for (auto j : sub.at(i))
            superset.insert(j);
    }
    for (int i = 0; i < n; ++i)
    {
        for (auto j : sub.at(i))
            superset.erase(superset.find(j));
        for (int k = 0; k < num.at(i).length(); ++k)
            for (int j = 0; j < num.at(i).length() - k; ++j)
            {
                if (superset.find(num.at(i).substr(j, k + 1)) == superset.end())
                {
                    std::cout << num.at(i).substr(j, k + 1) << "\n";
                    goto lab;
                }
            }
        lab:
        for (auto j : sub.at(i))
            superset.insert(j);
    }
}


#include <cmath>
#include <cassert>
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <set>
#include <fstream>

bool gl(char c)
{
    return c == 'a' || c == 'o' || c == 'u' || c == 'e' || c == 'i';
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    int n;
    std::cin >> n;
    std::vector<std::string> num;
    std::vector<std::vector<std::string>> sub;
    for (int i = 0; i < n; ++i)
    {
        std::string s;
        std::vector<std::string> set;
        std::cin >> s;
        for (int j = 0; j < s.length(); ++j)
        {
            for (int k = 0; k < s.length() - j; ++k)
            {
                set.push_back(s.substr(j, k + 1));
            }
        }
        sub.push_back(set);
        num.push_back(s);
    }
    std::multiset<std::string> superset;
    for (int i = 0; i < n; ++i)
    {
        for (auto j : sub.at(i))
            superset.insert(j);
    }
    for (int i = 0; i < n; ++i)
    {
        for (auto j : sub.at(i))
            superset.erase(superset.find(j));
        for (int k = 0; k < num.at(i).length(); ++k)
            for (int j = 0; j < num.at(i).length() - k; ++j)
            {
                if (superset.find(num.at(i).substr(j, k + 1)) == superset.end())
                {
                    std::cout << num.at(i).substr(j, k + 1) << "\n";
                    goto lab;
                }
            }
        lab:
        for (auto j : sub.at(i))
            superset.insert(j);
    }
}


#include <cmath>
#include <cassert>
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <set>
#include <fstream>
#include <unordered_set>

bool gl(char c)
{
    return c == 'a' || c == 'o' || c == 'u' || c == 'e' || c == 'i';
}

int main()
{
    std::ios_base::sync_with_stdio(false);
    int n;
    std::cin >> n;
    std::vector<std::string> num;
    std::vector<std::vector<std::string>> sub;
    for (int i = 0; i < n; ++i)
    {
        std::string s;
        std::vector<std::string> set;
        std::cin >> s;
        for (int j = 0; j < s.length(); ++j)
        {
            for (int k = 0; k < s.length() - j; ++k)
            {
                set.push_back(s.substr(j, k + 1));
            }
        }
        sub.push_back(set);
        num.push_back(s);
    }
    std::unordered_multiset<std::string> superset;
    for (int i = 0; i < n; ++i)
    {
        for (auto j : sub.at(i))
            superset.insert(j);
    }
    for (int i = 0; i < n; ++i)
    {
        for (auto j : sub.at(i))
            superset.erase(superset.find(j));
        for (int k = 0; k < num.at(i).length(); ++k)
            for (int j = 0; j < num.at(i).length() - k; ++j)
            {
                if (superset.find(num.at(i).substr(j, k + 1)) == superset.end())
                {
                    std::cout << num.at(i).substr(j, k + 1) << "\n";
                    goto lab;
                }
            }
        lab:
        for (auto j : sub.at(i))
            superset.insert(j);
    }
}


#include<bits/stdc++.h>

#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;

unordered_map<string, int> data;

int main() {
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    vector<string> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        for (int l = 1; l <= 9; ++l) {
            for (int ind = 0; ind < 10 - l; ++ind) {
                data[a[i].substr(ind, l)]++;

                //cout << a[i].substr(ind, l) << endl;
            }
        }
    }

    bool t = false;
    for (int i = 0; i < n; ++i) {
        t = false;
        for (int l = 1; l <= 9; ++l) {
            for (int ind = 0; ind < 10 - l; ++ind) {
                if (data[a[i].substr(ind, l)] == 1) {
                    cout << a[i].substr(ind, l) << endl;
                    t = true;
                    break;
                }
            }
            if (t)
                break;
        }
    }
}


#include<bits/stdc++.h>

#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;

unordered_map<string, int> data;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    vector<string> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        for (int l = 1; l <= 9; ++l) {
            for (int ind = 0; ind < 10 - l; ++ind) {
                data[a[i].substr(ind, l)]++;

                //cout << a[i].substr(ind, l) << endl;
            }
        }
    }

    bool t = false;
    for (int i = 0; i < n; ++i) {
        t = false;
        for (int l = 1; l <= 9; ++l) {
            for (int ind = 0; ind < 10 - l; ++ind) {
                if (data[a[i].substr(ind, l)] == 1) {
                    cout << a[i].substr(ind, l) << endl;
                    t = true;
                    break;
                }
            }
            if (t)
                break;
        }
    }
}


#include<bits/stdc++.h>

#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;

unordered_multiset<string> data;

int main() {
    int n;
    cin >> n;
    vector<string> a(n);
    unordered_set<string> s;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        s.clear();
        for (int l = 1; l <= 9; ++l) {
            for (int ind = 0; ind < 10 - l; ++ind) {
                if (s.find(a[i].substr(ind, l)) == s.end()) {
                    data.insert(a[i].substr(ind, l));
                    s.insert(a[i].substr(ind, l));
                }

                //cout << a[i].substr(ind, l) << endl;
            }
        }
    }

    bool t = false;
    for (int i = 0; i < n; ++i) {
        t = false;
        for (int l = 1; l <= 9; ++l) {
            for (int ind = 0; ind < 10 - l; ++ind) {
                if (data.count(a[i].substr(ind, l)) == 1) {
                    cout << a[i].substr(ind, l) << endl;
                    t = true;
                    break;
                }
            }
            if (t)
                break;
        }
    }
}


#include<bits/stdc++.h>

#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef long double ld;

unordered_map<string, int> data;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    vector<string> a(n);
    unordered_map<string, int> s;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        s.clear();
        for (int l = 1; l <= 9; ++l) {
            for (int ind = 0; ind < 10 - l; ++ind) {
                if (s[a[i].substr(ind, l)] == 0)
                    data[a[i].substr(ind, l)]++, s[a[i].substr(ind, l)]++;

                //cout << a[i].substr(ind, l) << endl;
            }
        }
    }

    bool t = false;
    for (int i = 0; i < n; ++i) {
        t = false;
        for (int l = 1; l <= 9; ++l) {
            for (int ind = 0; ind < 10 - l; ++ind) {
                if (data[a[i].substr(ind, l)] == 1) {
                    cout << a[i].substr(ind, l) << endl;
                    t = true;
                    break;
                }
            }
            if (t)
                break;
        }
    }
}


#include <bits/stdc++.h>

using namespace std;
int n;
string s[int(1e5)];
map <string, int> m;

inline void mark (string x, int id) {
	for (int i = 0; i < x.size(); ++i) {
		string cs = "";
		for (int j = i; j < x.size(); ++j) {
			cs += x[j];
			if (!m.count(cs)) m[cs] = id;
			else if (m[cs] != id) m[cs] = -1;
		}
	}
}

inline string dmark (string x, int id) {
	string ans = x;
	for (int i = 0; i < x.size(); ++i) {
		string cs = "";
		for (int j = i; j < x.size(); ++j) {
			cs += x[j];
			if (cs.size() >= ans.size()) break;
			if (m[cs] == id) ans = cs;
		}
	}
	return ans;
}

main (int argc, char * const argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> s[i];
		mark(s[i], i);
	}
	for (int i = 1; i <= n; ++i) cout << dmark(s[i], i) << '\n';
}


#include <bits/stdc++.h>

using namespace std;
int n;
string s[int(1e5)];
unordered_map <string, int> m;

inline void mark (string x, int id) {
	for (int i = 0; i < x.size(); ++i) {
		string cs = "";
		for (int j = i; j < x.size(); ++j) {
			cs += x[j];
			if (!m.count(cs)) m[cs] = id;
			else if (m[cs] != id) m[cs] = -1;
		}
	}
}

inline string dmark (string x, int id) {
	string ans = x;
	for (int i = 0; i < x.size(); ++i) {
		string cs = "";
		for (int j = i; j < x.size(); ++j) {
			cs += x[j];
			if (cs.size() >= ans.size()) break;
			if (m[cs] == id) ans = cs;
		}
	}
	return ans;
}

main (int argc, char * const argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> s[i];
		mark(s[i], i);
	}
	for (int i = 1; i <= n; ++i) cout << dmark(s[i], i) << '\n';
}


#include <bits/stdc++.h>

using namespace std;
int n;
string s[int(1e5)];
map <string, int> m;

void mark (string x, int id) {
	for (int i = 0; i < x.size(); i++) {
		string cs = "";
		for (int j = i; j < x.size(); j++) {
			cs += x[j];
			if (!m.count(cs)) m[cs] = id;
			else if (m[cs] != id) m[cs] = -1;
		}
	}
}

string dmark (string x, int id) {
	string ans = "aaaaaaaaaa";
	for (int i = 0; i < x.size(); i++) {
		string cs = "";
		for (int j = i; j < x.size(); j++) {
			cs += x[j];
			if (m.count(cs) && m[cs] == id) {
				if (cs.size() < ans.size()) ans = cs;
			}
		}
	}
	return ans;
}

main (int argc, char * const argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		mark(s[i], i);
	}
	for (int i = 1; i <= n; i++) cout << dmark(s[i], i) << endl;
}


#include <bits/stdc++.h>

using namespace std;
int n;
string s[int(1e5)];
map <string, int> m;

void mark (string x, int id) {
	for (int i = 0; i < x.size(); i++) {
		string cs = "";
		for (int j = i; j < x.size(); j++) {
			cs += x[j];
			if (!m.count(cs)) m[cs] = id;
			else if (m[cs] != id) m[cs] = -1;
		}
	}
}

string dmark (string x, int id) {
	string ans = "aaaaaaaaaa";
	for (int i = 0; i < x.size(); i++) {
		string cs = "";
		for (int j = i; j < x.size(); j++) {
			cs += x[j];
			if (m.count(cs) && m[cs] == id) {
				if (cs.size() < ans.size()) ans = cs;
			}
		}
	}
	return ans;
}

main (int argc, char * const argv[]) {
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		mark(s[i], i);
	}
	for (int i = 1; i <= n; i++) cout << dmark(s[i], i) << endl;
}


#include <bits/stdc++.h>

using namespace std;
int n;
string s[int(1e5)];
map <string, int> m;

void mark (string x, int id) {
	for (int i = 0; i < x.size(); i++) {
		string cs = "";
		for (int j = i; j < x.size(); j++) {
			cs += x[j];
			if (!m.count(cs)) m[cs] = id;
			else if (m[cs] != id) m[cs] = -1;
		}
	}
}

string dmark (string x, int id) {
	string ans = "aaaaaaaaaa";
	for (int i = 0; i < x.size(); i++) {
		string cs = "";
		for (int j = i; j < x.size(); j++) {
			cs += x[j];
			if (m[cs] == id) {
				if (cs.size() < ans.size()) ans = cs;
			}
		}
	}
	return ans;
}

main (int argc, char * const argv[]) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s[i];
		mark(s[i], i);
	}
	for (int i = 1; i <= n; i++) cout << dmark(s[i], i) << endl;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'

typedef long long ll;
typedef long double ld;

const ll p = (ll)1e+6 + 3ll, mod = (ll)1e+9 + 7ll;

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin >> n;

	unordered_map <ll, short> m;

	vector <string> arr(n);
	forn(i, n)
	{
		cin >> arr[i];
		ll h = 0ll;
		unordered_set <ll> ss;
		forn(z, arr[i].size())
		{
			ll h = 0ll;
			for (int j = z; j < arr[i].size(); j++)
			{
				h = (h * p + (ll)arr[i][j]) % mod;
				if (ss.count(h) == 0)
				{
					ss.insert(h);
					m[h]++;
				}
			}
		}
	}

	forn(i, n)
	{
		string ans = arr[i];
		ll h = 0ll;
		forn(z, arr[i].size())
		{
			ll h = 0ll;
			string cur = "";
			for (int j = z; j < arr[i].size(); j++)
			{
				cur += arr[i][j];
				h = (h * p + (ll)arr[i][j]) % mod;
				if (m[h] == 1)
				{
					if (ans.size() > cur.size())
						ans = cur;
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
#pragma comment(linker, "/STACK:256000000")
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'

typedef long long ll;
typedef long double ld;

const int alph = 10;

struct Node
{
	vector <int> next;
	set <int> term;

	Node()
	{
		this->next.resize(alph);
		forn(i, alph)
			this->next[i] = -1;
	}
};

vector <Node> trill(1, Node());

inline void add(const string &s, int num)
{
	int v = 0;
	forn(i, s.size())
	{
		int c = s[i] - '0';
		if (trill[v].next[c] != -1)
			v = trill[v].next[c];
		else
		{
			trill[v].next[c] = trill.size();
			v = trill.size();
			trill.push_back(Node());
		}
	}
	trill[v].term.insert(num);
}

bool get_cnt(const string &s)
{
	int v = 0;
	forn(i, s.size())
	{
		int c = s[i] - '0';
		v = trill[v].next[c];
	}
	return (trill[v].term.size() == 1);
}

string substr(int l, int r, const string &ish)
{
	string res = "";
	for (int i = l; i <= r; i++)
		res += ish[i];
	return res;
}

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin >> n;

	vector <string> arr(n);
	forn(i, n)
	{
		cin >> arr[i];
		for (int j = 0; j < arr[i].size(); j++)
		{
			string now = "";
			for (int z = j; z < arr[i].size(); z++)
			{
				now += arr[i][z];
				add(now, i);
			}
		}
	}

	forn(i, n)
	{
		string ans = "";
		int l = 1, r = arr[i].size();
		while (l != r)
		{
			int mid = (l + r) / 2;
			bool flag = false;

			for (int z = 0; z + mid - 1 < arr[i].size(); z++)
			{
				string cur = substr(z, z + mid - 1, arr[i]);
				bool res = get_cnt(cur);
				if (res)
				{
					flag = true;
					ans = cur;
					break;
				}
			}
			if (flag)
				r = mid;
			else
				l = mid + 1;
		}
		cout << ans << endl;
	}

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'

typedef long long ll;
typedef long double ld;

const int alph = 10;

struct Node
{
	vector <int> next;
	set <int> term;

	Node()
	{
		this->next.resize(alph);
		forn(i, alph)
			this->next[i] = -1;
	}
};

vector <Node> trill(1, Node());

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin >> n;

	vector <string> arr(n);
	forn(i, n)
	{
		cin >> arr[i];
		forn(z, arr[i].size())
		{
			int v = 0;
			for (int j = z; j < arr[i].size(); j++)
			{
				int c = arr[i][j] - '0';
				if (trill[v].next[c] != -1)
					v = trill[v].next[c];
				else
				{
					trill[v].next[c] = trill.size();
					v = trill.size();
					trill.push_back(Node());
				}
				trill[v].term.insert(i);
			}
		}
	}

	forn(i, n)
	{
		string ans = arr[i];
		forn(z, arr[i].size())
		{
			int v = 0;
			string cur = "";
			for (int j = z; j < arr[i].size(); j++)
			{
				cur += arr[i][j];
				v = trill[v].next[arr[i][j] - '0'];
				if (trill[v].term.size() == 1)
				{
					if (cur.size() < ans.size())
						ans = cur;
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
#pragma comment(linker, "/STACK:256000000")
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'

typedef long long ll;
typedef long double ld;

const int alph = 10;

struct Node
{
	vector <int> next;
	set <int> term;

	Node()
	{
		this->next.resize(alph);
		forn(i, alph)
			this->next[i] = -1;
	}
};

vector <Node> trill(1, Node());

inline void add(const string &s, int num)
{
	int v = 0;
	forn(i, s.size())
	{
		int c = s[i] - '0';
		if (trill[v].next[c] != -1)
			v = trill[v].next[c];
		else
		{
			trill[v].next[c] = trill.size();
			v = trill.size();
			trill.push_back(Node());
		}
	}
	trill[v].term.insert(num);
}

bool get_cnt(const string &s)
{
	int v = 0;
	forn(i, s.size())
	{
		int c = s[i] - '0';
		v = trill[v].next[c];
	}
	return (trill[v].term.size() == 1);
}

string substr(int l, int r, const string &ish)
{
	string res = "";
	for (int i = l; i <= r; i++)
		res += ish[i];
	return res;
}

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin >> n;

	vector <string> arr(n);
	forn(i, n)
	{
		cin >> arr[i];
		for (int j = 0; j < arr[i].size(); j++)
		{
			string now = "";
			for (int z = j; z < arr[i].size(); z++)
			{
				now += arr[i][z];
				add(now, i);
			}
		}
	}

	forn(i, n)
	{
		string ans = arr[i];
		int l = 1, r = arr[i].size();
		while (l != r)
		{
			int mid = (l + r) / 2;
			bool flag = false;

			for (int z = 0; z + mid - 1 < arr[i].size(); z++)
			{
				string cur = substr(z, z + mid - 1, arr[i]);
				bool res = get_cnt(cur);
				if (res)
				{
					flag = true;
					ans = cur;
					break;
				}
			}
			if (flag)
				r = mid;
			else
				l = mid + 1;
		}
		cout << ans << endl;
	}

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'

typedef long long ll;
typedef long double ld;

const int alph = 10;

struct Node
{
	int next[alph];
	int cnt;

	Node()
	{
		forn(i, alph)
			this->next[i] = -1;
		this->cnt = 0;
	}
};

vector <Node> trill(1, Node());

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n;
	cin >> n;

	vector <string> arr(n);
	forn(i, n)
	{
		cin >> arr[i];
		vector <bool> used((int)trill.size() + (int)arr[i].size() * (int)arr[i].size());
		forn(z, arr[i].size())
		{
			int v = 0;
			for (int j = z; j < arr[i].size(); j++)
			{
				int c = arr[i][j] - '0';
				if (trill[v].next[c] != -1)
					v = trill[v].next[c];
				else
				{
					trill[v].next[c] = trill.size();
					v = trill.size();
					trill.push_back(Node());
				}
				if (!used[v])
				{
					used[v] = true;
					trill[v].cnt++;
				}
			}
		}
	}

	forn(i, n)
	{
		string ans = arr[i];
		forn(z, arr[i].size())
		{
			int v = 0;
			string cur = "";
			for (int j = z; j < arr[i].size(); j++)
			{
				cur += arr[i][j];
				v = trill[v].next[arr[i][j] - '0'];
				if (trill[v].cnt == 1)
				{
					if (cur.size() < ans.size())
						ans = cur;
				}
			}
		}
		cout << ans << endl;
	}

	return 0;
}


/****************
*PID:
*Auth:Jonariguez
*****************
*/
#define lson k*2,l,m
#define rson k*2+1,m+1,r
#define rep(i,n) for(i=1;i<=(n);i++)
#define rep0(j,n) for(j=0;j<=(n);j++)
#define sc(x) scanf("%d",&x)
#define In(x) scanf("%I64d",&x)
#define SS(x,y) scanf("d",&x,&y)
#define pf(x) printf("%d",x)
#define pfn(x) printf("%d\n",(x))
#define Pf(x) printf("%I64d",(x))
#define Pfn(x) printf("%I64d\n",(x))
#define Pc printf(" ")
#define PY puts("YES")
#define PN puts("NO")
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define PI acos(-1.0)
#include <stdio.h>
#include <string.h>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef long long Ll;
Ll Pow(Ll a,Ll b,Ll MOD){a%=MOD;Ll res=1;while(b){if(b&1)res=(res*a)%MOD;b/=2;a=(a*a)%MOD;}return res;}

const int maxn=4000000+10;
const int MOD=1e9+7;

char str[70005][14];

struct Trie{
    int chi[maxn][11];
    int val[maxn];
    int sz;
    Trie(){sz=1;memset(chi[0],0,sizeof(chi[0])); }
    int idx(char c) { return c-'0';}
    void Insert(char *s){
        int u=0,n=strlen(s);
        for(int i=0;i<n;i++){
            int c=idx(s[i]);
            if(!chi[u][c]){
                memset(chi[sz],0,sizeof(chi[sz]));
                val[sz]=0;
                chi[u][c]=sz++;
            }
            u=chi[u][c];
            val[u]++;
        }
    }
    void Delete(char *s){
        int u=0,n=strlen(s);
        for(int i=0;i<n;i++){
            int c=idx(s[i]);
            u=chi[u][c];
            val[u]--;
        }
    }
    int ask(char *s){
        int cnt=0,u=0,n=strlen(s);
        for(int i=0;i<n;i++){
            int c=idx(s[i]);
            cnt++;
            if(!val[chi[u][c]]){
                return cnt;
            }
            u=chi[u][c];
        }
        return 11;
    }
}tree;

int main()
{
    int i,j,n;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%s",str[i]+1);
        for(j=1;j<=9;j++)
            tree.Insert(str[i]+j);
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=9;j++)
            tree.Delete(str[i]+j);
        int res=10,start,End;
        for(j=1;j<=9;j++){
            int c=tree.ask(str[i]+j);
            if(res>c){
                start=j;End=j+c-1;
            }
        }
        for(j=start;j<=End;j++)
            putchar(str[i][j]);
        puts("");
        for(j=1;j<=9;j++)
            tree.Insert(str[i]+j);
    }
    return 0;
}


/****************
*PID:
*Auth:Jonariguez
*****************
*/
#define lson k*2,l,m
#define rson k*2+1,m+1,r
#define rep(i,n) for(i=1;i<=(n);i++)
#define rep0(j,n) for(j=0;j<=(n);j++)
#define sc(x) scanf("%d",&x)
#define In(x) scanf("%I64d",&x)
#define SS(x,y) scanf("d",&x,&y)
#define pf(x) printf("%d",x)
#define pfn(x) printf("%d\n",(x))
#define Pf(x) printf("%I64d",(x))
#define Pfn(x) printf("%I64d\n",(x))
#define Pc printf(" ")
#define PY puts("YES")
#define PN puts("NO")
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define PI acos(-1.0)
#include <stdio.h>
#include <string.h>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef long long Ll;
Ll Pow(Ll a,Ll b,Ll MOD){a%=MOD;Ll res=1;while(b){if(b&1)res=(res*a)%MOD;b/=2;a=(a*a)%MOD;}return res;}

const int maxn=200000+10;
const int MOD=1e9+7;

map<string,int> mp1;
map<int,int> mp2,mp[maxn];
int Id;
char str[75000][12];

int ID(string &s){
    if(!mp1.count(s))
        mp1[s]=++Id;
    return mp1[s];
}

int main()
{
    int i,j,n;
    scanf("%d",&n);
    Id=0;
    string st;
    mp2.clear();
    mp1.clear();
    for(i=1;i<=n;i++){
        scanf("%s",str[i]+1);
        mp[i].clear();
        for(j=1;j<=9;j++){
            st="";
            for(int k=j;k<=9;k++){
                st+=str[i][k];
                int id=ID(st);
                mp[i][id]++;
                mp2[id]++;
            }
        }
    }
    string ans="";
    for(i=1;i<=n;i++){
        ans="";
        int len=10;
        for(j=1;j<=9;j++){
            st="";
            for(int k=j;k<=9;k++){
                st+=str[i][k];
                int id=ID(st);
                //cout<<st<<endl;
                if(mp[i][id]==mp2[id]){
                    if(len>k-j+1){
                        len=k-j+1;ans=st;
                    }
                    break;
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


/****************
*PID:
*Auth:Jonariguez
*****************
*/
#define lson k*2,l,m
#define rson k*2+1,m+1,r
#define rep(i,n) for(i=1;i<=(n);i++)
#define rep0(j,n) for(j=0;j<=(n);j++)
#define sc(x) scanf("%d",&x)
#define In(x) scanf("%I64d",&x)
#define SS(x,y) scanf("d",&x,&y)
#define pf(x) printf("%d",x)
#define pfn(x) printf("%d\n",(x))
#define Pf(x) printf("%I64d",(x))
#define Pfn(x) printf("%I64d\n",(x))
#define Pc printf(" ")
#define PY puts("YES")
#define PN puts("NO")
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define PI acos(-1.0)
#include <stdio.h>
#include <string.h>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef long long Ll;
Ll Pow(Ll a,Ll b,Ll MOD){a%=MOD;Ll res=1;while(b){if(b&1)res=(res*a)%MOD;b/=2;a=(a*a)%MOD;}return res;}

const int maxn=200000+10;
const int MOD=1e9+7;

map<string,int> mp1;
map<int,int> mp2,mp[maxn];
int Id;
char str[75000][12];

int ID(string &s){
    if(!mp1.count(s))
        mp1[s]=++Id;
    return mp1[s];
}

int main()
{
    int i,j,n;
    scanf("%d",&n);
    Id=0;
    string st;
    mp2.clear();
    mp1.clear();
    for(i=1;i<=n;i++){
        scanf("%s",str[i]+1);
        mp[i].clear();
        for(j=1;j<=9;j++){
            st="";
            for(int k=j;k<=9;k++){
                st+=str[i][k];
                int id=ID(st);
                mp[i][id]++;
                mp2[id]++;
            }
        }
    }
    string ans="";
    for(i=1;i<=n;i++){
        ans="";
        int len=10,star,End;
        for(j=1;j<=9;j++){
            st="";
            for(int k=j;k<=9;k++){
                if(k-j+1>len) break;
                st+=str[i][k];
                int id=ID(st);
                //cout<<st<<endl;
                if(mp[i][id]==mp2[id]){
                    if(len>k-j+1){
                        len=k-j+1;star=j;End=k;
                    }
                    break;
                }
            }
        }
        for(j=star;j<=End;j++) putchar(str[i][j]);
        puts("");
    }
    return 0;
}


/****************
*PID:
*Auth:Jonariguez
*****************
*/
#define lson k*2,l,m
#define rson k*2+1,m+1,r
#define rep(i,n) for(i=1;i<=(n);i++)
#define rep0(j,n) for(j=0;j<=(n);j++)
#define sc(x) scanf("%d",&x)
#define In(x) scanf("%I64d",&x)
#define SS(x,y) scanf("d",&x,&y)
#define pf(x) printf("%d",x)
#define pfn(x) printf("%d\n",(x))
#define Pf(x) printf("%I64d",(x))
#define Pfn(x) printf("%I64d\n",(x))
#define Pc printf(" ")
#define PY puts("YES")
#define PN puts("NO")
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define PI acos(-1.0)
#include <stdio.h>
#include <string.h>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef long long Ll;
Ll Pow(Ll a,Ll b,Ll MOD){a%=MOD;Ll res=1;while(b){if(b&1)res=(res*a)%MOD;b/=2;a=(a*a)%MOD;}return res;}

const int maxn=200000+10;
const int MOD=1e9+7;

map<string,int> mp1;
map<int,int> mp2,mp[maxn];
int Id;
char str[75000][12];

int ID(string &s){
    if(!mp1.count(s))
        mp1[s]=++Id;
    return mp1[s];
}

int main()
{
    int i,j,n;
    scanf("%d",&n);
    Id=0;
    string st;
    mp2.clear();
    mp1.clear();
    for(i=1;i<=n;i++){
        scanf("%s",str[i]+1);
        mp[i].clear();
        for(j=1;j<=9;j++){
            st="";
            for(int k=j;k<=9;k++){
                st+=str[i][k];
                int id=ID(st);
                mp[i][id]++;
                mp2[id]++;
            }
        }
    }
    string ans="";
    for(i=1;i<=n;i++){
        ans="";
        int len=10,star,End;
        for(j=1;j<=9;j++){
            st="";
            for(int k=j;k<=9;k++){
                st+=str[i][k];
                int id=ID(st);
                //cout<<st<<endl;
                if(mp[i][id]==mp2[id]){
                    if(len>k-j+1){
                        len=k-j+1;star=j;End=k;
                    }
                    break;
                }
            }
        }
        for(j=star;j<=End;j++) putchar(str[i][j]);
        puts("");
    }
    return 0;
}


/****************
*PID:
*Auth:Jonariguez
*****************
*/
#define lson k*2,l,m
#define rson k*2+1,m+1,r
#define rep(i,n) for(i=1;i<=(n);i++)
#define rep0(j,n) for(j=0;j<=(n);j++)
#define sc(x) scanf("%d",&x)
#define In(x) scanf("%I64d",&x)
#define SS(x,y) scanf("d",&x,&y)
#define pf(x) printf("%d",x)
#define pfn(x) printf("%d\n",(x))
#define Pf(x) printf("%I64d",(x))
#define Pfn(x) printf("%I64d\n",(x))
#define Pc printf(" ")
#define PY puts("YES")
#define PN puts("NO")
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define PI acos(-1.0)
#include <stdio.h>
#include <string.h>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef long long Ll;
Ll Pow(Ll a,Ll b,Ll MOD){a%=MOD;Ll res=1;while(b){if(b&1)res=(res*a)%MOD;b/=2;a=(a*a)%MOD;}return res;}

const int maxn=200000+10;
const int MOD=1e9+7;

map<string,int> mp1;
map<int,int> mp[maxn];
int mp2[maxn*2];
int Id;
char str[75000][12];

int ID(string &s){
    if(!mp1.count(s))
        mp1[s]=++Id;
    return mp1[s];
}

int main()
{
    int i,j,n;
    scanf("%d",&n);
    Id=0;
    string st;
    mp1.clear();
    for(i=1;i<=n;i++){
        scanf("%s",str[i]+1);
        mp[i].clear();
        for(j=1;j<=9;j++){
            st="";
            for(int k=j;k<=9;k++){
                st+=str[i][k];
                int id=ID(st);
                mp[i][id]++;
                mp2[id]++;
            }
        }
    }
    string ans="";
    for(i=1;i<=n;i++){
        ans="";
        int len=10,star,End;
        for(j=1;j<=9;j++){
            st="";
            for(int k=j;k<=9;k++){
                if(k-j+1>len) break;
                st+=str[i][k];
                int id=ID(st);
                //cout<<st<<endl;
                if(mp[i][id]==mp2[id]){
                    if(len>k-j+1){
                        len=k-j+1;star=j;End=k;
                    }
                    break;
                }
            }
        }
        for(j=star;j<=End;j++) putchar(str[i][j]);
        puts("");
    }
    return 0;
}


/****************
*PID:
*Auth:Jonariguez
*****************
*/
#define lson k*2,l,m
#define rson k*2+1,m+1,r
#define rep(i,n) for(i=1;i<=(n);i++)
#define rep0(i,n) for(i=0;j<=(n);i++)
#define re(i,n) for(i=1;i<(n);i++)
#define re0(i,n) for(i=0;i<(n);i++)
#define sc(x) scanf("%d",&x)
#define In(x) scanf("%I64d",&x)
#define SS(x,y) scanf("%d%d",&x,&y)
#define pf(x) printf("%d",x)
#define pfn(x) printf("%d\n",(x))
#define Pf(x) printf("%I64d",(x))
#define Pfn(x) printf("%I64d\n",(x))
#define Pc printf(" ")
#define PY puts("YES")
#define PN puts("NO")
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define PI acos(-1.0)
#include <stdio.h>
#include <string.h>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef long long Ll;
Ll Pow(Ll a,Ll b,Ll MOD){a%=MOD;Ll res=1;while(b){if(b&1)res=(res*a)%MOD;b/=2;a=(a*a)%MOD;}return res;}

const int maxn=4000000+10;
const int MOD=1e9+7;

char str[70005][14];

struct Trie{
    int chi[maxn][11];
    int val[maxn];
    int sz;
    Trie(){sz=1;memset(chi[0],0,sizeof(chi[0])); }
    int idx(char c) { return c-'0';}
    void Insert(char *s){
        int u=0,n=strlen(s),i;
        re0(i,n){
            int c=idx(s[i]);
            if(!chi[u][c]){
                memset(chi[sz],0,sizeof(chi[sz]));
                val[sz]=0;
                chi[u][c]=sz++;
            }
            u=chi[u][c];
            val[u]++;
        }
    }
    void Delete(char *s){
        int u=0,n=strlen(s),i;
        re0(i,n){
            int c=idx(s[i]);
            u=chi[u][c];
            val[u]--;
        }
    }
    int ask(char *s){
        int cnt=0,u=0,n=strlen(s),i;
        re0(i,n){
            int c=idx(s[i]);
            cnt++;
            if(!val[chi[u][c]]){
                return cnt;
            }
            u=chi[u][c];
        }
        return 11;
    }
}tree;

int main()
{
    int i,j,n;
    scanf("%d",&n);
    rep(i,n){
        scanf("%s",str[i]+1);
        for(j=1;j<=9;j++)
            tree.Insert(str[i]+j);
    }
    for(i=1;i<=n;i++){
        rep(j,9)
            tree.Delete(str[i]+j);
        int res=10,start,End;
        for(j=1;j<=9;j++){
            int c=tree.ask(str[i]+j);
            if(res>c){
                start=j;End=j+c-1;res=c;
            }
        }
        for(j=start;j<=End;j++)
            putchar(str[i][j]);
        puts("");
        for(j=1;j<=9;j++)
            tree.Insert(str[i]+j);
    }
    return 0;
}


/****************
*PID:
*Auth:Jonariguez
*****************
*/
#define lson k*2,l,m
#define rson k*2+1,m+1,r
#define rep(i,n) for(i=1;i<=(n);i++)
#define rep0(j,n) for(j=0;j<=(n);j++)
#define sc(x) scanf("%d",&x)
#define In(x) scanf("%I64d",&x)
#define SS(x,y) scanf("d",&x,&y)
#define pf(x) printf("%d",x)
#define pfn(x) printf("%d\n",(x))
#define Pf(x) printf("%I64d",(x))
#define Pfn(x) printf("%I64d\n",(x))
#define Pc printf(" ")
#define PY puts("YES")
#define PN puts("NO")
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define PI acos(-1.0)
#include <stdio.h>
#include <string.h>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef long long Ll;
Ll Pow(Ll a,Ll b,Ll MOD){a%=MOD;Ll res=1;while(b){if(b&1)res=(res*a)%MOD;b/=2;a=(a*a)%MOD;}return res;}

const int maxn=200000+10;
const int MOD=1e9+7;

map<string,int> mp1;
map<int,int> mp[maxn];
int mp2[maxn*20];
int Id;
char str[75000][12];

int ID(string &s){
    if(!mp1.count(s))
        mp1[s]=++Id;
    return mp1[s];
}

int main()
{
    int i,j,n;
    scanf("%d",&n);
    Id=0;
    string st;
    mp1.clear();
    for(i=1;i<=n;i++){
        scanf("%s",str[i]+1);
        mp[i].clear();
        for(j=1;j<=9;j++){
            st="";
            for(int k=j;k<=9;k++){
                st+=str[i][k];
                int id=ID(st);
                mp[i][id]++;
                mp2[id]++;
            }
        }
    }
    string ans="";
    for(i=1;i<=n;i++){
        ans="";
        int len=10,star,End;
        for(j=1;j<=9;j++){
            st="";
            for(int k=j;k<=9;k++){
                if(k-j+1>len) break;
                st+=str[i][k];
                int id=ID(st);
                //cout<<st<<endl;
                if(mp[i][id]==mp2[id]){
                    if(len>k-j+1){
                        len=k-j+1;star=j;End=k;
                    }
                    break;
                }
            }
        }
        for(j=star;j<=End;j++) putchar(str[i][j]);
        puts("");
    }
    return 0;
}


/****************
*PID:
*Auth:Jonariguez
*****************
*/
#define lson k*2,l,m
#define rson k*2+1,m+1,r
#define rep(i,n) for(i=1;i<=(n);i++)
#define rep0(j,n) for(j=0;j<=(n);j++)
#define sc(x) scanf("%d",&x)
#define In(x) scanf("%I64d",&x)
#define SS(x,y) scanf("d",&x,&y)
#define pf(x) printf("%d",x)
#define pfn(x) printf("%d\n",(x))
#define Pf(x) printf("%I64d",(x))
#define Pfn(x) printf("%I64d\n",(x))
#define Pc printf(" ")
#define PY puts("YES")
#define PN puts("NO")
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define PI acos(-1.0)
#include <stdio.h>
#include <string.h>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef long long Ll;
Ll Pow(Ll a,Ll b,Ll MOD){a%=MOD;Ll res=1;while(b){if(b&1)res=(res*a)%MOD;b/=2;a=(a*a)%MOD;}return res;}

const int maxn=200000+10;
const int MOD=1e9+7;

char str[70005][14];

struct Trie{
    int chi[maxn][11];
    int val[maxn];
    int sz;
    Trie(){sz=1;memset(chi[0],0,sizeof(chi[0])); }
    int idx(char c) { return c-'0';}
    void Insert(char *s){
        int u=0,n=strlen(s);
        for(int i=0;i<n;i++){
            int c=idx(s[i]);
            if(!chi[u][c]){
                memset(chi[sz],0,sizeof(chi[sz]));
                val[sz]=0;
                chi[u][c]=sz++;
            }
            u=chi[u][c];
            val[u]++;
        }
    }
    void Delete(char *s){
        int u=0,n=strlen(s);
        for(int i=0;i<n;i++){
            int c=idx(s[i]);
            u=chi[u][c];
            val[u]--;
        }
    }
    int ask(char *s){
        int cnt=0,u=0,n=strlen(s);
        for(int i=0;i<n;i++){
            int c=idx(s[i]);
            cnt++;
            if(!val[chi[u][c]]){
                return cnt;
            }
            u=chi[u][c];
        }
        return 11;
    }
}tree;

int main()
{
    int i,j,n;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%s",str[i]+1);
        for(j=1;j<=9;j++)
            tree.Insert(str[i]+j);
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=9;j++)
            tree.Delete(str[i]+j);
        int res=10,start,End;
        for(j=1;j<=9;j++){
            int c=tree.ask(str[i]+j);
            if(res>c){
                start=j;End=j+c-1;
            }
        }
        for(j=start;j<=End;j++)
            putchar(str[i][j]);
        puts("");
        for(j=1;j<=9;j++)
            tree.Insert(str[i]+j);
    }
    return 0;
}


/****************
*PID:
*Auth:Jonariguez
*****************
*/
#define lson k*2,l,m
#define rson k*2+1,m+1,r
#define rep(i,n) for(i=1;i<=(n);i++)
#define rep0(j,n) for(j=0;j<=(n);j++)
#define sc(x) scanf("%d",&x)
#define In(x) scanf("%I64d",&x)
#define SS(x,y) scanf("d",&x,&y)
#define pf(x) printf("%d",x)
#define pfn(x) printf("%d\n",(x))
#define Pf(x) printf("%I64d",(x))
#define Pfn(x) printf("%I64d\n",(x))
#define Pc printf(" ")
#define PY puts("YES")
#define PN puts("NO")
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define PI acos(-1.0)
#include <stdio.h>
#include <string.h>
#include <string>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef long long Ll;
Ll Pow(Ll a,Ll b,Ll MOD){a%=MOD;Ll res=1;while(b){if(b&1)res=(res*a)%MOD;b/=2;a=(a*a)%MOD;}return res;}

const int maxn=4000000+10;
const int MOD=1e9+7;

char str[70005][14];

struct Trie{
    int chi[maxn][11];
    int val[maxn];
    int sz;
    Trie(){sz=1;memset(chi[0],0,sizeof(chi[0])); }
    int idx(char c) { return c-'0';}
    void Insert(char *s){
        int u=0,n=strlen(s);
        for(int i=0;i<n;i++){
            int c=idx(s[i]);
            if(!chi[u][c]){
                memset(chi[sz],0,sizeof(chi[sz]));
                val[sz]=0;
                chi[u][c]=sz++;
            }
            u=chi[u][c];
            val[u]++;
        }
    }
    void Delete(char *s){
        int u=0,n=strlen(s);
        for(int i=0;i<n;i++){
            int c=idx(s[i]);
            u=chi[u][c];
            val[u]--;
        }
    }
    int ask(char *s){
        int cnt=0,u=0,n=strlen(s);
        for(int i=0;i<n;i++){
            int c=idx(s[i]);
            cnt++;
            if(!val[chi[u][c]]){
                return cnt;
            }
            u=chi[u][c];
        }
        return 11;
    }
}tree;

int main()
{
    int i,j,n;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        scanf("%s",str[i]+1);
        for(j=1;j<=9;j++)
            tree.Insert(str[i]+j);
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=9;j++)
            tree.Delete(str[i]+j);
        int res=10,start,End;
        for(j=1;j<=9;j++){
            int c=tree.ask(str[i]+j);
            if(res>c){
                start=j;End=j+c-1;res=c;
            }
        }
        for(j=start;j<=End;j++)
            putchar(str[i][j]);
        puts("");
        for(j=1;j<=9;j++)
            tree.Insert(str[i]+j);
    }
    return 0;
}


#include <iostream>
#include <fstream>
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <unordered_map>
using namespace std;

int n ;
set < string >  v ;
unordered_map <string, int> st ;
string a[200000], ans[200000] ;

int main()
{
    ios_base :: sync_with_stdio( false ) ;

    int i, j, k ;
    string x ;
    char c ;

    scanf ( "%d", &n ) ;
    scanf ( "%c", &c ) ;

    for ( i=1; i<=n; i++ )
    {
        a[i] = "" ;
        for ( j=0; j<9; j++ )
        {
           scanf ( "%c", &c ) ;
           a[i] += c ;
        }
        scanf ( "%c", &c ) ;

        v.clear() ;

        for ( j=0; j<9; j++ )
         for ( k=j; k<9; k++ )
         {
           x = "" ;

           for ( int u=j; u<=k; u++ )
              x += a[i][u] ;

           v.insert ( x ) ;
         }

        for ( set<string> :: iterator it = v.begin(); it != v.end(); it ++ )
           if ( st[ *it ] == 0 )
                st[ *it ] = i ;
           else
                st[ *it ] = -1 ;
    }

    for ( i=1; i<=n; i++ )
       ans[i] = "                   " ;

    for ( unordered_map<string, int> :: iterator it = st.begin(); it != st.end();  it++ )
    {
        pair <string, int> p = *it ;

        if ( p.second > -1  &&  ans[p.second].size() > p.first.size() )
            ans[p.second] = p.first ;
    }

     for ( i=1; i<=n; i++ )
     {
       for ( j=0; j<ans[i].size(); j++ )
          printf( "%c", ans[i][j] ) ;
       printf( "\n" ) ;
     }

    return 0;
}


#include <iostream>
#include <fstream>
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
using namespace std;

int n ;
set < string >  v ;
unordered_multiset < string > st ;
string a[200000] ;

int main()
{
    ios_base :: sync_with_stdio( false ) ;

    int i, j, k ;
    string x ;
    char c ;

    scanf ( "%d", &n ) ;
    scanf ( "%c", &c ) ;

    for ( i=1; i<=n; i++ )
    {
        a[i] = "" ;
        for ( j=0; j<9; j++ )
        {
           scanf ( "%c", &c ) ;
           a[i] += c ;
        }
        scanf ( "%c", &c ) ;

        v.clear() ;

        for ( j=0; j<9; j++ )
         for ( k=j; k<9; k++ )
         {
           x = "" ;

           for ( int u=j; u<=k; u++ )
              x += a[i][u] ;

           v.insert ( x ) ;
         }

        for ( set<string> :: iterator it = v.begin(); it != v.end(); it ++ )
            st.insert ( *it ) ;
    }

    for ( i=1; i<=n; i++ )
    {
        string ans = "                  "  ;

       for ( k=0; k<=9; k++ )
       {
        bool f = false ;

        for ( j=0; j+k<9; j++ )
         {
           x = "" ;

           for ( int u=j; u<=j+k; u++ )
              x += a[i][u] ;

            if ( st.count( x ) == 1  )
            {
                 ans = x ;
                 f = true ;
                 break ;
            }
         }

         if ( f )
            break ;
       }

       for ( j=0; j<ans.size(); j++ )
          printf( "%c", ans[j] ) ;
       printf( "\n" ) ;
    }

    return 0;
}


#include <iostream>
#include <fstream>
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;

int n ;
set < string >  v ;
multiset < string > st ;
string a[200000] ;

int main()
{
    ios_base :: sync_with_stdio( false ) ;

    int i, j, k ;
    string x ;
    char c ;

    scanf ( "%d", &n ) ;
    scanf ( "%c", &c ) ;

    for ( i=1; i<=n; i++ )
    {
        a[i] = "" ;
        for ( j=0; j<9; j++ )
        {
           scanf ( "%c", &c ) ;
           a[i] += c ;
        }
        scanf ( "%c", &c ) ;

        v.clear() ;

        for ( j=0; j<9; j++ )
         for ( k=j; k<9; k++ )
         {
           x = "" ;

           for ( int u=j; u<=k; u++ )
              x += a[i][u] ;

           v.insert ( x ) ;
         }

        for ( set<string> :: iterator it = v.begin(); it != v.end(); it ++ )
            st.insert ( *it ) ;
    }

    for ( i=1; i<=n; i++ )
    {
        string ans = "                  "  ;

       for ( k=0; k<=9; k++ )
       {
        bool f = false ;

        for ( j=0; j+k<9; j++ )
         {
           x = "" ;

           for ( int u=j; u<=j+k; u++ )
              x += a[i][u] ;

            if ( st.count( x ) == 1  )
            {
                 ans = x ;
                 f = true ;
                 break ;
            }
         }

         if ( f )
            break ;
       }

       for ( j=0; j<ans.size(); j++ )
          printf( "%c", ans[j] ) ;
       printf( "\n" ) ;
    }

    return 0;
}


#include <iostream>
#include <fstream>
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;

int n ;
set < string >  v ;
multiset < string > st ;
string a[200000] ;

int main()
{
    ios_base :: sync_with_stdio( false ) ;

    int i, j, k ;
    string x ;

    cin >> n ;
    for ( i=1; i<=n; i++ )
    {
        cin >> a[i] ;

        v.clear() ;

        for ( j=0; j<9; j++ )
         for ( k=j; k<9; k++ )
         {
           x = "" ;

           for ( int u=j; u<=k; u++ )
              x += a[i][u] ;

           v.insert ( x ) ;
         }

        for ( set<string> :: iterator it = v.begin(); it != v.end(); it ++ )
            st.insert ( *it ) ;
    }

    for ( i=1; i<=n; i++ )
    {
        string ans = "                  "  ;

        for ( j=0; j<9; j++ )
         for ( k=j; k<9; k++ )
         {
           x = "" ;

           for ( int u=j; u<=k; u++ )
              x += a[i][u] ;

            if ( st.count( x ) == 1  &&  x.length() < ans.length() )
                 ans = x ;

         }

        cout << ans << endl ;
    }

    return 0;
}


#include <iostream>
#include <fstream>
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;

int n ;
set < string >  v ;
multiset < string > st ;
string a[200000] ;

int main()
{
    ios_base :: sync_with_stdio( false ) ;

    int i, j, k ;
    string x ;
    char c ;

    scanf ( "%d", &n ) ;
    scanf ( "%c", &c ) ;

    for ( i=1; i<=n; i++ )
    {
        a[i] = "" ;
        for ( j=0; j<9; j++ )
        {
           scanf ( "%c", &c ) ;
           a[i] += c ;
        }
        scanf ( "%c", &c ) ;

        v.clear() ;

        for ( j=0; j<9; j++ )
         for ( k=j; k<9; k++ )
         {
           x = "" ;

           for ( int u=j; u<=k; u++ )
              x += a[i][u] ;

           v.insert ( x ) ;
         }

        for ( set<string> :: iterator it = v.begin(); it != v.end(); it ++ )
            st.insert ( *it ) ;
    }

    for ( i=1; i<=n; i++ )
    {
        string ans = "                  "  ;

        for ( j=0; j<9; j++ )
         for ( k=j; k<9; k++ )
         {
           x = "" ;

           for ( int u=j; u<=k; u++ )
              x += a[i][u] ;

            if ( st.count( x ) == 1  &&  x.length() < ans.length() )
                 ans = x ;

         }

       for ( j=0; j<ans.size(); j++ )
          printf( "%c", ans[j] ) ;
       printf( "\n" ) ;
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
map<string,pair<int,int> > m;
map<string,pair<int,int> >::iterator it;
string w[70009];
main()
{
	int i,n,j,k;
	string s,q;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		cin >> s;
		w[i]=s;
		for(j=0;j<9;j++)
		{
			q=s[j];
			m[q].first++;
			if(m[q].second==i+1)m[q].first--;
			m[q].second=i+1;
			for(k=j+1;k<9;k++)
			{
				q+=s[k];
				m[q].first++;
			if(m[q].second==i+1)m[q].first--;
			m[q].second=i+1;
			}
		}
	}
	bool g;
	for(i=0;i<n;i++)
	{
		s=w[i];
		g=0;
		for(j=1;j<=9;j++)
		{
			for(k=0;k+j<=9;k++)
			{
				q=s.substr(k,j);
				if(m[q].first==1)
				{
					g=1;
					cout << q << endl;
					break;
				}
			}
			if(g==1)break;
		}

	}
}


#include<bits/stdc++.h>
using namespace std;
map<string,int> m;
map<string,int>::iterator it;
string w[70009];
main()
{
	int i,n,j,k;
	string s,q;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		cin >> s;
		w[i]=s;
		for(j=0;j<9;j++)
		{
			q=s[j];
			if(m[q]==0||m[q]==i+1)
			m[q]=i+1;
			else m[q]=-1;
			for(k=j+1;k<9;k++)
			{
				q+=s[k];
				if(m[q]==0||m[q]==i+1)
				m[q]=i+1;
				else m[q]=-1;
			}
		}
	}
	for(it=m.begin();it!=m.end();it++)
	{
		if(it->second!=-1&&w[it->second-1].size()>it->first.size())
		{

			w[it->second-1]=it->first;
		}
	}
	for(i=0;i<n;i++)
	{
		cout << w[i] << endl;
	}

}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<string,int>mapp;
string ans[7007];
int main()
{
    int n;
    string s;
	cin>>n;

    for(int ii=1;ii<=n;ii++)
    {
        cin>>s;
        string temp;
        for(int i=0;i<s.length();i++)
        {
            temp="";
            for(int j=i;j<s.length();j++)
            {
                temp+=s[j];
                if(mapp[temp]&&mapp[temp]!=ii)
                {
                    mapp[temp]=-1;
                }
                else
                {
                    mapp[temp]=ii;
                }
            }
        }
    }
   map<string,int>::iterator it;
    for(it=mapp.begin();it!=mapp.end();it++)
    {
       // cout<<it->second<<" "<<it->first<<endl;
        if(it->second!=-1)
        if(ans[it->second]==""||ans[it->second].size()>((it->first).size()))
           {
               ans[it->second]=(it->first);
           }
    }
    for(int i=1;i<=n;i++)
    {
        cout<<ans[i]<<endl;
    }

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
map<string,int>mapp;
string ans[70007];
int main()
{
    int n;
    string s;
	cin>>n;

    for(int ii=1;ii<=n;ii++)
    {
        cin>>s;
        string temp;
        for(int i=0;i<s.length();i++)
        {
            temp="";
            for(int j=i;j<s.length();j++)
            {
                temp+=s[j];
                if(mapp[temp]&&mapp[temp]!=ii)
                {
                    mapp[temp]=-1;
                }
                else
                {
                    mapp[temp]=ii;
                }
            }
        }
    }
   map<string,int>::iterator it;
    for(it=mapp.begin();it!=mapp.end();it++)
    {
       // cout<<it->second<<" "<<it->first<<endl;
        if(it->second!=-1)
        if(ans[it->second]==""||ans[it->second].size()>((it->first).size()))
           {
               ans[it->second]=(it->first);
           }
    }
    for(int i=1;i<=n;i++)
    {
        cout<<ans[i]<<endl;
    }

	return 0;
}


#include <iostream>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

map<string,int>m;
int n;
string s[70005];

int main()
{
    cin >> n;
    for(int i = 1 ; i <= n ; i++)
    {
        cin >> s[i];
        for(int j = 0 ; j < s[i].size() ; j++)
            for(int k = j ; k < s[i].size() ; k++){
                string temp="";
                for(int p = j ; p <= k ; p++)
                    temp += s[i][p];
                m[temp]++;
            }
    }
    for(int i = 1 ; i <= n ; i++)
    {
        string minim="999999999999";
        int mis = 10;
        for(int j = 0 ; j < s[i].size() ; j++){
            for(int k = j ; k < s[i].size() ; k++){
                string temp="";
                for(int p = j ; p <= k ; p++)
                    temp += s[i][p];
                if(m[temp] == 1)
                {
                    if(mis > temp.size())
                    {
                        mis = temp.size();
                        minim = temp;
                    }
                }
            }
        }
        cout << minim << "\n";
    }
    return 0;
}


#include <iostream>
#include <map>
#include <string>
#include <algorithm>
#include <set>

using namespace std;

map<string,int>m;
int n;
string s[70005];

int main()
{
    cin >> n;
    for(int i = 1 ; i <= n ; i++)
    {
        cin >> s[i];
        set<string>st;
        for(int j = 0 ; j < s[i].size() ; j++)
            for(int k = 0 ; k+j < s[i].size() ; k++){
                string temp="";
                for(int p = j ; p <= k+j ; p++)
                    temp += s[i][p];
                st.insert(temp);
            }
        for(auto it : st)
            m[it]++;
    }
    for(int i = 1 ; i <= n ; i++)
    {
        string minim="999999999999";
        int mis = 10;
        for(int j = 0 ; j < s[i].size() ; j++){
            for(int k = 0 ; k+j < s[i].size() ; k++){
                string temp="";
                for(int p = j ; p <= k+j ; p++)
                    temp += s[i][p];
                if(m[temp] == 1)
                {
                    if(mis > temp.size())
                    {
                        mis = temp.size();
                        minim = temp;
                    }
                }
            }
        }
        cout << minim << "\n";
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define int int64_t
int getHash(string str) {
    int g = 1;
    for(int i = 0; i<str.size(); ++i) {
        g = g * 10 + str[i] - '0';
    }
    return g;
}
int getSize(int h) {
    int ans = 0;
    while(h) {
        ++ans;
        h/=10;
    }
    return ans;
}
int remFirst(int n) {
    return (n%int(pow(10.0, double(getSize(n) - 1))));
}
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
int32_t main() {
    //ios_base::sync_with_stdio(false);
    freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    map<int, set<int> > m;
    string str;
    for(int i = 0; i<n; ++i) {
         int f;
         cin >> f;
         str = SSTR(f);
         int g = getHash(str);
         int h = str.size();
         for(int l = 0; l<h; ++l) {
            for(int len = 1; len<=h - l; ++len) {
                m[getHash(str.substr(l, len))].insert(i);
            }
         }

    }
    vector<set<pair<int, int> > > v(n);
    for(map<int, set<int> >::iterator iter = m.begin(); iter!=m.end(); ++iter) {
        set<int> st = (*iter).second;
        if(st.size()!=1) continue;
        int str = (*iter).first;
        v[*st.begin()].insert(pair<int, int>(getSize(str), str));
    }
    for(int i = 0; i<n; ++i) {
        cout << remFirst((*v[i].begin()).second) << "\n";
    }
}


#include <bits/stdc++.h>

using namespace std;
#define int int64_t
int32_t main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    map<string, set<int> > m;
    for(int i = 0; i<n; ++i) {
         string str;
         cin >> str;
         int h = str.size();
         for(int l = 0; l<h; ++l) {
            for(int len = 1; len<=h - l; ++len) {
                m[str.substr(l, len)].insert(i);
            }
         }
    }
    vector<set<pair<int, string> > > v(n);
    for(map<string, set<int> >::iterator iter = m.begin(); iter!=m.end(); ++iter) {
        set<int> st = (*iter).second;
        if(st.size()!=1) continue;
        string str = (*iter).first;
        v[*st.begin()].insert(pair<int, string>(str.size(), str));
    }
    for(int i = 0; i<n; ++i) {
        cout << (*v[i].begin()).second << endl;
    }
}


#include <bits/stdc++.h>

using namespace std;
#define int int64_t
int32_t main() {
    ios_base::sync_with_stdio(false);
    freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    map<string, set<int> > m;
    for(int i = 0; i<n; ++i) {
         string str;
         cin >> str;
         int h = str.size();
         for(int l = 0; l<h; ++l) {
            for(int len = 1; len<=h - l; ++len) {
                m[str.substr(l, len)].insert(i);
            }
         }

    }
    vector<set<pair<int, string> > > v(n);
    for(map<string, set<int> >::iterator iter = m.begin(); iter!=m.end(); ++iter) {
        set<int> st = (*iter).second;
        if(st.size()!=1) continue;
        string str = (*iter).first;
        v[*st.begin()].insert(pair<int, string>(str.size(), str));
    }
    for(int i = 0; i<n; ++i) {
        cout << (*v[i].begin()).second << "\n";
    }
}


#include <bits/stdc++.h>

using namespace std;
#define int int64_t
int32_t main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    map<string, set<int> > m;
    for(int i = 0; i<n; ++i) {
         string str;
         cin >> str;
         int h = str.size();
         for(int l = 0; l<h; ++l) {
            for(int len = 1; len<=h - l; ++len) {
                m[str.substr(l, len)].insert(i);
            }
         }

    }
    vector<set<pair<int, string> > > v(n);
    for(map<string, set<int> >::iterator iter = m.begin(); iter!=m.end(); ++iter) {
        set<int> st = (*iter).second;
        if(st.size()!=1) continue;
        string str = (*iter).first;
        v[*st.begin()].insert(pair<int, string>(str.size(), str));
    }
    for(int i = 0; i<n; ++i) {
        cout << (*v[i].begin()).second << "\n";
    }
}


#include <bits/stdc++.h>
using namespace std;
#define int int64_t
int getHash(string str) {
    int g = 1;
    for(int i = 0; i<str.size(); ++i) {
        g = g * 10 + str[i] - '0';
    }
    return g;
}
int getSize(int h) {
    int ans = 0;
    while(h) {
        ++ans;
        h/=10;
    }
    return ans;
}
int remFirst(int n) {
    return (n%int(pow(10.0, double(getSize(n) - 1))));
}
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
int32_t main() {
    ios_base::sync_with_stdio(false);
    freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    map<int, set<int> > m;
    string str;
    for(int i = 0; i<n; ++i) {
         int f;
         cin >> f;
         str = SSTR(f);
         int g = getHash(str);
         int h = str.size();
         for(int l = 0; l<h; ++l) {
            for(int len = 1; len<=h - l; ++len) {
                m[getHash(str.substr(l, len))].insert(i);
            }
         }

    }
    vector<set<pair<int, int> > > v(n);
    for(map<int, set<int> >::iterator iter = m.begin(); iter!=m.end(); ++iter) {
        set<int> st = (*iter).second;
        if(st.size()!=1) continue;
        int str = (*iter).first;
        v[*st.begin()].insert(pair<int, int>(getSize(str), str));
    }
    for(int i = 0; i<n; ++i) {
        cout << remFirst((*v[i].begin()).second) << "\n";
    }
}


#include <bits/stdc++.h>
using namespace std;
#define int int64_t
int getHash(string str) {
    int g = 0;
    for(int i = 0; i<str.size(); ++i) {
        g = g * 11 + str[i] - '0' + 1;
    }
    return g;
}
int getSize(int h) {
    int ans = 0;
    while(h) {
        ++ans;
        h/=10;
    }
    return ans;
}
string unHash(int n) {
    string str = "";
    while(n) {
        str+=n%11 + '0' - 1;
        n/=11;
    }
    return string(str.rbegin(), str.rend());
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    map<int, set<int> > m;
    string str;
    for(int i = 0; i<n; ++i) {
         cin >> str;
         int g = getHash(str);
         int h = str.size();
         for(int l = 0; l<h; ++l) {
            for(int len = 1; len<=h - l; ++len) {
                m[getHash(str.substr(l, len))].insert(i);
            }
         }

    }
    vector<set<pair<int, int> > > v(n);
    for(map<int, set<int> >::iterator iter = m.begin(); iter!=m.end(); ++iter) {
        set<int> st = (*iter).second;
        if(st.size()!=1) continue;
        int str = (*iter).first;
        v[*st.begin()].insert(pair<int, int>(getSize(str), str));
    }
    for(int i = 0; i<n; ++i) {
        cout << unHash((*v[i].begin()).second) << "\n";
    }
}


#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<set>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<string> a(n);
    map<string, int> c;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        set<string> s;
        for (int j = 0; j < 9; j++)
        {
            string s2 = "";
            for (int k = j; k < 9; k++)
            {
                s2 += a[i][k];
                if (s.find(s2) == s.end())
                {
                    c[s2]++;
                    s.insert(s2);
                }
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        string ans = a[i];
        for (int j = 0; j < 9; j++)
        {
            string s2 = "";
            for (int k = j; k < 9; k ++)
            {
                s2 += a[i][k];
                if (c[s2] == 1 && s2.size() < ans.size())
                    ans = s2;
            }
        }
        cout << ans << endl;
    }
}


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

//-----------------------------------------------------------------

int main()
{

  map<string,int> combs[9]; // 1 dig, 2 dig, ..., 9 dig
  vector<string> numbers;
  string numb;
  int n;

  //FILE *lun = fopen("b1.in","r");
  //fscanf(lun,"%s",s);
  //scanf("%d",&nstud);
  //std::ifstream cin("a1.in");
  cin >> n;

  for (int i = 0; i < n; ++i) {
    cin >> numb;
    numbers.push_back(numb);

    int ndig = 0; // 1 digit
    while (ndig < 9) {

      int len = ndig + 1;
      for (int j = 0; j < 9; ++j) {
	if (j + ndig >= 9) break;
	string comb = numb.substr(j,len);
	if (combs[ndig].find(comb) == combs[ndig].end()) combs[ndig][comb] = i;
	else if (combs[ndig][comb] != i) combs[ndig][comb] = -1; // ne odna combinatsiya
      }
      ++ndig;
    }

  }

  vector<string> codes(n,"-1");
  for (int i = 0; i < 9; ++i) {

    for (map<string,int>::iterator it = combs[i].begin(); it != combs[i].end(); ++it) {
      if (it->second == -1) continue;
      else if (codes[it->second] == "-1") codes[it->second] = it->first;
    }
  }

  for (int i = 0; i < n; ++i) cout << codes[i] << endl;
}


#include<iostream>
#include<vector>
#include<map>
#include<string>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<string> a(n);
    map<string, pair<int, int>> c;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        for (int j = 0; j < 9; j++)
        {
            string s2 = "";
            for (int k = j; k < 9; k++)
            {
                s2 += a[i][k];
                if ((c[s2]).second != i + 1)
                {
                    c[s2].first++;
                    c[s2].second = i + 1;
                }
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        string ans = a[i];
        for (int j = 0; j < 9; j++)
        {
            string s2 = "";
            for (int k = j; k < 9; k ++)
            {
                s2 += a[i][k];
                if (c[s2].first == 1 && s2.size() < ans.size())
                    ans = s2;
            }
        }
        cout << ans << endl;
    }
}


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

#define endl '\n'
#define ll long long
#define ldb long double
#define pb push_back
#define sz size
#define F first
#define S second

int inf =1e9, qq, sz, n, f = 1e9, mn = 1e9 ;
const int N=1e5+10, mod = 1e9+7;
vector<string>v, one[N];
map<string, int>mp;
bool comp(string a , string b){
return a.size() <=b.size();
}
struct pp
{
    string ss;
} a[N];
string s ="";
int main()
{
#ifdef Mohammad
    freopen("input.in","r",stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n ;
    for (int i=1; i<=n; i++){

        cin >> s ;
       // v.pb(s);
        for(int j = 0; j<s.size(); j++){

            string k = "";
            for (int u = j; u<s.size(); u++){

                k+=s[u];
                one[i].pb(k);
                mp[k]++;
            }
        }
sort(one[i].begin() , one[i].end() , comp);

    }
    for (int i=1; i<=n; i++){
        f = 1e9;
        for (auto y : one[i])
            mp[y]--;

        for (auto y:one[i])
            if (mp[y] == 0){
                    a[i].ss = y;
                 break;
            }

        for (auto y : one[i])
            mp[y]++;
    }

    for (int i=1;i<=n;i++)
        cout<<a[i].ss<<"\n";

}


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

#define endl '\n'
#define ll long long
#define ldb long double
#define pb push_back
#define sz size
#define F first
#define S second

int inf =1e9, qq, sz, n, f = 1e9, mn = 1e9 ;
const int N=1e5+10, mod = 1e9+7;
vector<string>v, one[N];
map<string, pair< int, int> >mp;
bool comp(string a , string b){
return a.size() <=b.size();
}
struct pp
{
    string ss = "00000000000";
} a[N];
string s ="";
int main()
{
#ifdef Mohammad
    freopen("input.in","r",stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n ;
    for (int i=1; i<=n; i++){

        cin >> s ;
       // v.pb(s);
        for(int j = 0; j<s.size(); j++){

            string k = "";
            for (int u = j; u<s.size(); u++){

                k+=s[u];
                one[i].pb(k);
                if (mp[k].S != i)
                mp[k].F++;
                mp[k].S = i;
            }
        }
    }
    for (auto y : mp){
        if (y.S.F == 1){
            if (a[y.S.S].ss.size()>y.F.size())
                a[y.S.S].ss = y.F;
        }

    }

    for (int i=1;i<=n;i++)
        cout<<a[i].ss<<"\n";

}


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

#define endl '\n'
#define ll long long
#define ldb long double
#define pb push_back
#define sz size
#define F first
#define S second

int inf =1e9, qq, sz, n, f = 1e9, mn = 1e9 ;
const int N=1e5+10, mod = 1e9+7;
vector<string>v, one[N];
map<string, int>mp;
struct pp
{
    string ss;
} a[N];
string s ="";
int main()
{
#ifdef Mohammad
    freopen("input.in","r",stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> n ;
    for (int i=1; i<=n; i++)
    {
        cin >> s ;
       // v.pb(s);
        for(int j = 0; j<s.size(); j++)
        {
            string k = "";
            for (int u = j; u<s.size(); u++)
            {
                k+=s[u];
                one[i].pb(k);
                mp[k]++;
            }
        }

    }

    for (int i=1; i<=n; i++)
    {
        f = 1e9;

        for (auto y : one[i])
            mp[y]--;

        for (auto y:one[i])
        {
            if (!mp[y])
            {
                if (f > y.size())
                {
                    a[i].ss = y;
                    f = y.size();
                }
            }
        }
        for (auto y : one[i])
            mp[y]++;
    }
    for (int i=1;i<=n;i++)
        cout<<a[i].ss<<"\n";

}


#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<time.h>
#include<climits>
#include<cmath>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<iomanip>

//#define IONAME "cttf"
//#define E_DEBUG
//#define TIMECOMP

int n,q;
int a[222000],s[222000],e[222000],io[222000],ss[222000],ee[222000];

void marota(){
    std::cin>>n>>q;
    for (int i=1;i<=n;i++) {
        std::cin>>a[i];
        if (a[i]>q)
        {
            std::cout<<"NO\n";
            return;
        }
        if (!s[a[i]]) s[a[i]]=i;
        e[a[i]]=std::max(e[a[i]],i);
    }
    int i=1;
    while (a[i]==0&& i<=n) {
        i++;
    }
    if (i==n+1) {
        std::cout<<"YES\n";
        for (int i=1;i<n;i++) std::cout<<1<<" ";
        std::cout<<q;
        return ;
    }
    for (int j=i-1;j>=1;j--) a[j]=a[j+1];
    std::vector<int> tmp;
    tmp.clear();
    int err=0;
    if (!s[q]) err=1;
    for (;i<=n;i++){
        if (a[i]!=0){
            if (tmp.size()) if (tmp.back()>a[i])
            {
                std::cout<<"NO\n";
                return;
            }
            if (s[a[i]]==i) tmp.push_back(a[i]);
            if (e[a[i]]==i) tmp.pop_back();
        }
        else{
            if (!s[q]){
                err=0;
                a[i]=q;
                s[q]=n+1;
            }
            else if (tmp.empty()) {
                a[i]=a[i-1];
            }
            else {
                a[i]=tmp.back();
            }
        }
    }
    if (err)
    {
        std::cout<<"NO\n";
        return;
    }
    std::cout<<"YES\n";
    for (int i=1;i<=n;i++) std::cout<<a[i]<<" ";
}

int main(){
    #ifdef TIMECOMP
    clock_t tStart = clock();
    #endif
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    #if defined(IONAME)
    freopen(IONAME".INP","r",stdin);
    freopen(IONAME".OUT","w",stdout);
    #endif
    marota();
    #ifdef TIMECOMP
    printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    #endif
    return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<time.h>
#include<climits>
#include<cmath>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<iomanip>

//#define IONAME "cttf"
//#define E_DEBUG
//#define TIMECOMP

int n,m;
std::map <std::string ,int> mps,tmp;
std::string s[77000];
void marota(){
    std::cin>>n;
    for (int k=1;k<=n;k++){
        std::cin>>s[k];
        tmp.clear();
        for (int i=0;i<s[k].length();i++){
            for (int j=i;j>=0;j--){
                std::string tmps=s[k].substr(j,i-j+1);
                if (!tmp[tmps]){
                    tmp[tmps]=1;
                    mps[tmps]++;
                }
            }
        }
    }
    for (int k=1;k<=n;k++){
        tmp.clear();
        std::string res=s[k];
        for (int i=0;i<s[k].length();i++){
            for (int j=i;j>=0;j--){
                std::string tmps=s[k].substr(j,i-j+1);
                if (mps[tmps]==1){
                    if (res.size()>tmps.size()) res=tmps;
                }
            }
        }
        std::cout<<res<<"\n";
    }
}

int main(){
    #ifdef TIMECOMP
    clock_t tStart = clock();
    #endif
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    #if defined(IONAME)
    freopen(IONAME".INP","r",stdin);
    freopen(IONAME".OUT","w",stdout);
    #endif
    marota();
    #ifdef TIMECOMP
    printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    #endif
    return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<time.h>
#include<climits>
#include<cmath>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<iomanip>

//#define IONAME "cttf"
//#define E_DEBUG
//#define TIMECOMP

int n,m;
std::map <std::string ,int> mps,tmp;
std::string s[77000];
void marota(){
    std::cin>>n;
    for (int k=1;k<=n;k++){
        std::cin>>s[k];
        tmp.clear();
        for (int i=0;i<s[k].length();i++){
            for (int j=i;j>=0;j--){
                std::string tmps=s[k].substr(j,i-j+1);
                if (!tmp[tmps]){
                    tmp[tmps]=1;
                    mps[tmps]++;
                }
            }
        }
    }
    for (int k=1;k<=n;k++){
        std::string res=s[k];
        for (int i=0;i<s[k].length();i++){
            for (int j=i;j>=0;j--){
                std::string tmps=s[k].substr(j,i-j+1);
                if (mps[tmps]==1){
                    if (res.size()>tmps.size()) res=tmps;
                }
            }
        }
        std::cout<<res<<"\n";
    }
}

int main(){
    #ifdef TIMECOMP
    clock_t tStart = clock();
    #endif
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    #if defined(IONAME)
    freopen(IONAME".INP","r",stdin);
    freopen(IONAME".OUT","w",stdout);
    #endif
    marota();
    #ifdef TIMECOMP
    printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    #endif
    return 0;
}


#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<time.h>
#include<climits>
#include<cmath>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<set>
#include<iomanip>

//#define IONAME "cttf"
//#define E_DEBUG
//#define TIMECOMP

int n,m;
std::map <int,int> mps[10],tmp[10];
int up10[100];
int s[77000];
void marota(){
    std::cin>>n;
    up10[0]=1;
    for (int i=1;i<=9;i++)  up10[i]=up10[i-1]*10;
    for (int k=1;k<=n;k++){
        std::cin>>s[k];
        for (int i=0;i<=9;i++) tmp[i].clear();
        for (int i=1;i<=9;i++){
            for (int j=i-1;j>=0;j--){
                int tmps=(s[k]%up10[i])/up10[j];
                //std::cout<<tmps<<'\n';
                if (!tmp[i-j][tmps]){
                    tmp[i-j][tmps]=1;
                    mps[i-j][tmps]++;
                }
            }
        }
        //std::cout<<'\n';
    }
    for (int k=1;k<=n;k++){
        int res=s[k];
        int lgs=9;
        for (int i=1;i<=9;i++){
            for (int j=i-1;j>=0;j--){
                int tmps=(s[k]%up10[i])/up10[j];
                if (mps[i-j][tmps]==1){
                    if (lgs>i-j) {
                        res=tmps;
                        lgs=i-j;
                    }
                }
            }
        }
        for (int i=1;i<=lgs-std::to_string(res).length();i++){
            std::cout<<0;
        }
        std::cout<<res<<"\n";
    }
}

int main(){
    #ifdef TIMECOMP
    clock_t tStart = clock();
    #endif
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);
    #if defined(IONAME)
    freopen(IONAME".INP","r",stdin);
    freopen(IONAME".OUT","w",stdout);
    #endif
    marota();
    #ifdef TIMECOMP
    printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
    #endif
    return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

signed main() {
	int n; cin >> n;

	vector <string> v(n);
	map <string, int> matc;

	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
		set <string> subss;
		for (int j = 0; j < 9; j++)
		{
			for (int k = 0; k + j < 9; k++)
			{
				subss.insert(v[i].substr(k, j + 1));
			}
		}
		for (const auto & it : subss)
		{
			matc[it]++;
		}
	}

	for (int i = 0; i < n; i++)
	{
		string ans = "";
		for (int j = 0; j < 9; j++)
		{
			for (int k = 0; k + j < 9; k++)
			{
				string subs = v[i].substr(k, j + 1);
				if (matc[subs] == 1)
				{
					ans = subs;
					break;
				}
			}
			if (ans != "")      break;
		}
		cout << ans << "\n";
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

signed main() {
	int n; cin >> n;

	vector <string> v(n);
	map <string, int> matc;

	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
		set <string> subss;
		for (int j = 0; j < 9; j++)
		{
			for (int k = 0; k + j < 9; k++)
			{
				subss.insert(v[i].substr(k, j + 1));
			}
		}
		for (const auto & it : subss)
		{
			matc[it]++;
		}
	}

	for (int i = 0; i < n; i++)
	{
		string ans = "";
		for (int j = 0; j < 9; j++)
		{
			for (int k = 0; k + j < 9; k++)
			{
				string subs = v[i].substr(k, j + 1);
				if (matc[subs] == 1)
				{
					ans = subs;
					break;
				}
			}
			if (ans != "")      break;
		}
		cout << ans << "\n";
	}
	system("pause");
	return 0;
}


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

string s[100000];
map <string, int> q;
map <string, int> g[100000];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    set <string> sub;
    for (int i = 0; i < n; i++) {
        sub.clear();
        for (int j = 0; j < s[i].length(); j++) {
            for (int k = 1; k <= s[i].length() - j; k++) {
                sub.insert(s[i].substr(j,k));
            }
        }
        for (const auto &j : sub) {
            q[j]++;
        }
    }
    for (int i = 0; i < n; i++) {
        int u = 0;
        for (int k = 1; k <= s[i].length(); k++) {
            for (int j = 0; j < s[i].length() - k + 1; j++) {
                string subs = s[i].substr(j,k);
                if (q[subs] == 1) {
                    cout << subs << endl;
                    u = 1;
                }
                if (u != 0) {j = 1e6;}
            }
            if (u != 0) {k = 1e6;}
        }
    }
}


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

string s[100000];
map <string, int> q;
map <string, int> g[100000];

int main()
{
    ios_base :: sync_with_stdio(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    set <string> sub;
    for (int i = 0; i < n; i++) {
        sub.clear();
        for (int j = 0; j < s[i].length(); j++) {
            for (int k = 1; k <= s[i].length() - j; k++) {
                sub.insert(s[i].substr(j,k));
            }
        }
        for (const auto &j : sub) {
            q[j]++;
        }
    }
    for (int i = 0; i < n; i++) {
        int u = 0;
        for (int k = 1; k <= s[i].length(); k++) {
            for (int j = 0; j < s[i].length() - k + 1; j++) {
                string subs = s[i].substr(j,k);
                if (q[subs] == 1) {
                    cout << subs << endl;
                    u = 1;
                }
                if (u != 0) break;
            }
            if (u != 0) break;
        }
    }
}


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

int main()
{
    ios_base :: sync_with_stdio(0);
    string s[70001];
    map <string, int> q;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        set <string> sub;
        for (int j = 0; j < 9; j++) {
            for (int k = 1; k <= 9 - j; k++) {
                sub.insert(s[i].substr(j,k));
            }
        }
        for (const auto &j : sub) {
            q[j]++;
        }
    }
    for (int i = 0; i < n; i++) {
        int u = 0;
        for (int k = 1; k <= 9 k++) {
            for (int j = 0; j < 9 - k + 1; j++) {
                string subs = s[i].substr(j,k);
                if (q[subs] == 1) {
                    cout << subs << endl;
                    u = 1;
                }
                if (u != 0) break;
            }
            if (u != 0) break;
        }
    }
}


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

int main()
{
    ios_base :: sync_with_stdio(0);
    string s[100000];
    map <string, int> q;    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        set <string> sub;
        for (int j = 0; j < s[i].length(); j++) {
            for (int k = 1; k <= s[i].length() - j; k++) {
                sub.insert(s[i].substr(j,k));
            }
        }
        for (const auto &j : sub) {
            q[j]++;
        }
    }
    for (int i = 0; i < n; i++) {
        int u = 0;
        for (int k = 1; k <= s[i].length(); k++) {
            for (int j = 0; j < s[i].length() - k + 1; j++) {
                string subs = s[i].substr(j,k);
                if (q[subs] == 1) {
                    cout << subs << endl;
                    break;
                }
            }
            if (u != 0) break;
        }
    }
}


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

string s[100000];
map <string, int> q;
map <string, int> g;
string z[70001][10][10];

int main()
{
    ios_base :: sync_with_stdio(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        for (int j = 0; j < s[i].length(); j++) {
            for (int k = 1; k <= s[i].length()-j; k++) {
                z[i][j][k] = s[i].substr(j,k);
            }
        }
    }
    for (int i = 0; i < n; i++) {
        g.clear();
        for (int j = 0; j < s[i].length(); j++) {
            for (int k = 1; k <= s[i].length() - j; k++) {
                if (g[z[i][j][k]] == 0) {
                    q[z[i][j][k]]++;
                    g[z[i][j][k]]++;
                }
            }
        }
    }
    for (int i = 0; i < n; i++) {
        int u = 0;
        for (int k = 1; k <= s[i].length(); k++) {
            for (int j = 0; j < s[i].length() - k + 1; j++) {
                if (q[z[i][j][k]] == 1) {
                    cout << z[i][j][k] << endl;
                    u = 1;
                }
                if (u != 0) {j = 1e6;}
            }
            if (u != 0) {k = 1e6;}
        }
    }
}


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

string s[100000];
map <string, int> q;
map <string, int> g[100000];
string z[70001][10][10];

int main()
{
    ios_base :: sync_with_stdio(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        for (int j = 0; j < s[i].length(); j++) {
            for (int k = 1; k <= s[i].length()-j; k++) {
                z[i][j][k] = s[i].substr(j,k);
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < s[i].length(); j++) {
            for (int k = 1; k <= s[i].length() - j; k++) {
                q[z[i][j][k]]++;
                g[i][z[i][j][k]]++;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        int u = 0;
        for (int k = 1; k <= s[i].length(); k++) {
            for (int j = 0; j < s[i].length() - k + 1; j++) {
                if (q[z[i][j][k]] == g[i][z[i][j][k]]) {
                    cout << z[i][j][k] << endl;
                    u = 1;
                }
                if (u != 0) {j = 1e6;}
            }
            if (u != 0) {k = 1e6;}
        }
    }
}


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

string s[100000];
map <string, int> q;
map <string, int> g[100000];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < s[i].length(); j++) {
            for (int k = 1; k <= s[i].length() - j; k++) {
                q[s[i].substr(j,k)]++;
                g[i][s[i].substr(j,k)]++;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        int u = 0;
        for (int k = 1; k <= s[i].length(); k++) {
            for (int j = 0; j < s[i].length() - k + 1; j++) {
                if (q[s[i].substr(j,k)] == g[i][s[i].substr(j,k)]) {
                    cout << s[i].substr(j,k) << endl;
                    u = 1;
                }
                if (u != 0) {j = 1e6;}
            }
            if (u != 0) {k = 1e6;}
        }
    }
}


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

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    map <string, int> q;
    int n;
    string s[70001];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        set <string> sub;
        for (int j = 0; j < 9; j++) {
            string ss = "";
            for (int k = 1; k <= 9 - j; k++) {
                ss = ss + s[i][j+k-1];
                sub.insert(ss);
            }
        }
        for (const auto &j : sub) {
            q[j]++;
        }
    }
    for (int i = 0; i < n; i++) {
        int u = 0;
        for (int k = 1; k <= 9; k++) {
            for (int j = 0; j + k < 10; j++) {
                string subs = s[i].substr(j,k);
                if (q[subs] == 1) {
                    cout << subs << endl;
                    u = 1;
                }
                if (u != 0) break;
            }
            if (u != 0) break;
        }
    }
    return 0;
}


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

string s[100000];
map <string, int> q;
map <string, int> g[100000];

int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    set <string> sub;
    for (int i = 0; i < n; i++) {
        sub.clear();
        for (int j = 0; j < s[i].length(); j++) {
            for (int k = 1; k <= s[i].length() - j; k++) {
                sub.insert(s[i].substr(j,k));
            }
        }
        for (const auto &j : sub) {
            q[j]++;
        }
    }
    for (int i = 0; i < n; i++) {
        int u = 0;
        for (int k = 1; k <= s[i].length(); k++) {
            for (int j = 0; j < s[i].length() - k + 1; j++) {
                if (q[s[i].substr(j,k)] == 1) {
                    cout << s[i].substr(j,k) << endl;
                    u = 1;
                }
                if (u != 0) {j = 1e6;}
            }
            if (u != 0) {k = 1e6;}
        }
    }
}


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

int main()
{
    ios_base :: sync_with_stdio(0);
    map <string, int> q;
    int n;
    vector <string> s(n+1);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        set <string> sub;
        for (int j = 0; j < 9; j++) {
            for (int k = 1; k <= 9 - j; k++) {
                sub.insert(s[i].substr(j,k));
            }
        }
        for (const auto &j : sub) {
            q[j]++;
        }
    }
    for (int i = 0; i < n; i++) {
        int u = 0;
        for (int k = 1; k <= 9; k++) {
            for (int j = 0; j < 9 - k + 1; j++) {
                string subs = s[i].substr(j,k);
                if (q[subs] == 1) {
                    cout << subs << endl;
                    u = 1;
                }
                if (u != 0) break;
            }
            if (u != 0) break;
        }
    }
}


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

int main()
{
    ios_base :: sync_with_stdio(false);
    map <string, int> q;
    int n;
    string s[70001];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        set <string> sub;
        for (int j = 0; j < 9; j++) {
            string ss = "";
            for (int k = 1; k <= 9 - j; k++) {
                ss = ss + s[i][j+k-1];
                sub.insert(ss);
            }
        }
        for (const auto &j : sub) {
            q[j]++;
        }
    }
    for (int i = 0; i < n; i++) {
        int u = 0;
        for (int k = 1; k <= 9; k++) {
            for (int j = 0; j < 9 - k + 1; j++) {
                string subs = s[i].substr(j,k);
                if (q[subs] == 1) {
                    cout << subs << endl;
                    u = 1;
                }
                if (u != 0) break;
            }
            if (u != 0) break;
        }
    }
}


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

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    map <string, int> q;
    int n;
    string s[70001];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        set <string> sub;
        for (int j = 0; j < 9; j++) {
            string ss = "";
            for (int k = 1; k <= 9 - j; k++) {
                ss = ss + s[i][j+k-1];
                sub.insert(ss);
            }
        }
        for (const auto &j : sub) {
            q[j]++;
        }
    }
    for (int i = 0; i < n; i++) {
        int u = 0;
        for (int k = 1; k <= 9; k++) {
            for (int j = 0; j + k < 10; j++) {
                string subs = s[i].substr(j,k);
                if (q[subs] == 1) {
                    cout << subs << endl
                    u = 1;
                }
                if (u != 0) break;
            }
            if (u != 0) break;
        }
    }
    return 0;
}


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

int main()
{
    ios_base :: sync_with_stdio(0);
    map <string, int> q;
    int n;
    string s[70001];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        set <string> sub;
        for (int j = 0; j < 9; j++) {
            string ss = "";
            for (int k = 1; k <= 9 - j; k++) {
                ss = ss + s[i][j+k-1];
                sub.insert(ss);
            }
        }
        for (const auto &j : sub) {
            q[j]++;
        }
    }
    for (int i = 0; i < n; i++) {
        int u = 0;
        for (int k = 1; k <= 9; k++) {
            for (int j = 0; j + k < 10; j++) {
                string subs = s[i].substr(j,k);
                if (q[subs] == 1) {
                    cout << subs << "\n";
                    u = 1;
                }
                if (u != 0) break;
            }
            if (u != 0) break;
        }
    }
    return 0;
}


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

int main()
{
    ios_base :: sync_with_stdio(0);
    string s[70001];
    map <string, int> q;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        set <string> sub;
        for (int j = 0; j < 9; j++) {
            for (int k = 1; k <= 9 - j; k++) {
                sub.insert(s[i].substr(j,k));
            }
        }
        for (const auto &j : sub) {
            q[j]++;
        }
    }
    for (int i = 0; i < n; i++) {
        int u = 0;
        for (int k = 1; k <= 9; k++) {
            for (int j = 0; j < 9 - k + 1; j++) {
                string subs = s[i].substr(j,k);
                if (q[subs] == 1) {
                    cout << subs << endl;
                    u = 1;
                }
                if (u != 0) break;
            }
            if (u != 0) break;
        }
    }
}


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

int main()
{
    ios_base :: sync_with_stdio(0);
    string s[100000];
    map <string, int> q;    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        set <string> sub;
        for (int j = 0; j < s[i].length(); j++) {
            for (int k = 1; k <= s[i].length() - j; k++) {
                sub.insert(s[i].substr(j,k));
            }
        }
        for (const auto &j : sub) {
            q[j]++;
        }
    }
    for (int i = 0; i < n; i++) {
        int u = 0;
        for (int k = 1; k <= s[i].length(); k++) {
            for (int j = 0; j < s[i].length() - k + 1; j++) {
                string subs = s[i].substr(j,k);
                if (q[subs] == 1) {
                    cout << subs << endl;
                    u = 1;
                    break;
                }
            }
            if (u != 0) break;
        }
    }
}


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

string s[70001];
map <string, int> q;
map <string, int> g[70001];
string z[70001][9][9];

int main()
{
    ios_base :: sync_with_stdio(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        for (int j = 0; j < s[i].length(); j++) {
            for (int k = 1; k <= s[i].length()-j; k++) {
                z[i][j][k] = s[i].substr(j,k);
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < s[i].length(); j++) {
            for (int k = 1; k <= s[i].length() - j; k++) {
                q[z[i][j][k]]++;
                g[i][z[i][j][k]]++;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        int u = 0;
        for (int k = 1; k <= s[i].length(); k++) {
            for (int j = 0; j < s[i].length() - k + 1; j++) {
                if (q[z[i][j][k]] == g[i][z[i][j][k]]) {
                    cout << z[i][j][k] << endl;
                    u = 1;
                }
                if (u != 0) {j = 1e6;}
            }
            if (u != 0) {k = 1e6;}
        }
    }
}


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

int main()
{
    ios_base :: sync_with_stdio(0);
    string s[100000];
    map <string, int> q;    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        set <string> sub;
        for (int j = 0; j < s[i].length(); j++) {
            for (int k = 1; k <= s[i].length() - j; k++) {
                sub.insert(s[i].substr(j,k));
            }
        }
        for (const auto &j : sub) {
            q[j]++;
        }
    }
    for (int i = 0; i < n; i++) {
        int u = 0;
        for (int k = 1; k <= s[i].length(); k++) {
            for (int j = 0; j < s[i].length() - k + 1; j++) {
                string subs = s[i].substr(j,k);
                if (q[subs] == 1) {
                    cout << subs << endl;
                    u = 1;
                }
                if (u != 0) break;
            }
            if (u != 0) break;
        }
    }
}