#include <cstdio>
#include <queue>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <set>
#include <cmath>
#include <numeric> //accumulate
#include <stack>
#include <bitset>

//#include <unordered_set>//unordered_set

#define rep(i,a) for (int i = 0; i < (a); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define PI 3.14159265359;

using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef const vector<int> cvi;
typedef vector<bool> vb;

//const ll INF = 1ull << 62;
const int INF = 987654321;
const int MOD = 1000000007;

vvi adj;
vi sccId, dscv;
stack<int> st;
int sccCnt, vtxCnt;
int scc(int here) {
	int ret = dscv[here] = vtxCnt++;
	st.push(here);
	rep(i, adj[here].size()) {
		int there = adj[here][i];
		if (dscv[there] == -1)
			ret = min(ret, scc(there));
		else if (dscv[there] < dscv[here] && sccId[there] == -1)
			return min(ret, dscv[there]);
	}
	if (ret == dscv[here]) {
		while (true) {
			int t = st.top(); st.pop();
			sccId[t] = sccCnt;
			if (t == here) break;
		}
		++sccCnt;
	}
	return ret;
}
vi tarjanSCC() {
	sccId = dscv = vi(adj.size(), -1);
	sccCnt = vtxCnt = 0;
	rep(i, adj.size()) if (dscv[i] == -1) scc(i);
	return sccId;
}
set<int> ddSet;
void makeGraph(const vi& meetings) {
	int mtSize = meetings.size();
	adj.clear();
	adj.resize(mtSize * 2);
	// left 가 두개 이상 있는 놈들을 따로 기록
	map<int, int> mm;
	for (int i = 0; i < mtSize; i += 2) {
		mm[meetings[i]]++;
	}
	for (int i = 0; i < mtSize; i += 2) {
		if (mm[meetings[i]] > 1)
			ddSet.insert(i);	// 왼쪽이 같은게 두개 이상인 것들을 기록
	}
	/*
	for (int i = 0; i < mtSize; i += 2) {
		if (ddSet.count(i)) {	// 왼쪽이 무조건 선택 안되는 경우 처리
			int j = i + 1;	// 오른쪽을 항상 참으로 : (!R U R) => R->!R, !R->R
			adj[j * 2].push_back(j * 2 + 1);
			adj[j * 2 + 1].push_back(j * 2);
		}
	}
	*/
	multiset<int>::iterator it = ddSet.begin();
	for (; it != ddSet.end(); ++it) {
		int trueNode = *it * 2;
		int falseNode = *it * 2 + 1;
		adj[trueNode].push_back(falseNode);
	}
	for (int i = 0; i < mtSize; i += 2) {
		//if (ddSet.count(i)) continue;	// 왼쪽은 무조건 선택 안함.
		int j = i + 1;
		adj[i * 2 + 1].push_back(j * 2);
		adj[j * 2 + 1].push_back(i * 2);
	}
	for (int i = 0; i < mtSize; ++i)
		for (int j = 0; j < i; ++j) {
			if (meetings[i] == meetings[j]) {
				adj[i * 2].push_back(j * 2 + 1);
				adj[j * 2].push_back(i * 2 + 1);
			}
		}
}
vi solve2SAT() {
	vi label = tarjanSCC();
	for (int i = 0; i < adj.size(); i += 2) if (label[i] == label[i + 1]) return vi();
	vpii order;
	for (int i = 0; i < adj.size(); ++i) order.push_back(mp(-label[i], i));
	sort(order.begin(), order.end());
	vi vbChoose(adj.size() / 2, -1); // 선택여부
	for (int i = 0; i < order.size(); ++i) {
		int node = order[i].second;
		int index = node / 2;
		if (ddSet.count(index)) {
			vbChoose[index] = false;
			vbChoose[index + 1] = true;
			continue;
		}
		if (vbChoose[index] != -1) continue;
		vbChoose[index] = !((node % 2) == 0);
	}
	return vbChoose;
}
vi solve(const vi& meetings) {
	makeGraph(meetings);
	vi ret = solve2SAT();
	return ret;
}
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	vi meetings(n * 2);
	map<string, int> my;
	map<int, string> myR;
	int index = 0;
	rep(i, n) {
		string str1, str2;	cin >> str1 >> str2;
		str1 = str1.substr(0, 3);
		str2 = str1.substr(0, 2) + str2[0];
		if (my.count(str1) == 0) {
			myR[index] = str1;  my[str1] = index++;
		}
		if (my.count(str2) == 0) {
			myR[index] = str2;	my[str2] = index++;
		}
		meetings[i * 2] = my[str1];
		meetings[i * 2 + 1] = my[str2];
	}
	vi value = solve(meetings);
	if (value.empty()) cout << "NO";
	else {
		cout << "YES" << '\n';
		for (int i = 0; i < 2 * n; i += 2) {
			if (value[i] == 1) {
				int idx = meetings[i];
				cout << myR[idx] << '\n';
			}
			else {
				int idx = meetings[i+1];
				cout << myR[idx] << '\n';
			}
		}
	}
	return 0;
}


#include <cstdio>
#include <queue>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <set>
#include <cmath>
#include <numeric> //accumulate
#include <stack>
#include <bitset>

//#include <unordered_set>//unordered_set

#define rep(i,a) for (int i = 0; i < (a); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define PI 3.14159265359;

	using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef const vector<int> cvi;
typedef vector<bool> vb;

//const ll INF = 1ull << 62;
const int INF = 987654321;
const int MOD = 1000000007;
// 앞이 같은 놈이 존재시 뒤를 선택한다.
// 이때 뒤도 같으면 망한다.
// 또한 모든 선택된 것은 달라야 한다.
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	vector<pair<string, string>> arr(n);
	rep(i, n) {
		string str1, str2; cin >> str1 >> str2;
		arr[i].first = str1.substr(0, 3);
		arr[i].second = str1.substr(0, 2) + str2[0];
	}
	map<string, int> my, my2;
	rep(i, n) my[arr[i].first]++;
	vi choose(n, 0);
	rep(i, n) if (my[arr[i].first] > 1) {
		choose[i] = 1;	// 두번째꺼 선택
		my2[arr[i].second]++;	// 선택된거 기록
	}
	map<string, int>::iterator it = my2.begin();
	for (; it != my2.end(); ++it) if (it->second > 1) {
		cout << "NO"; return 0;
	}
	rep(i, n) {
		if (choose[i] == 1) continue;
		string key = arr[i].first;
		if (my2.count(key) > 0) {
			string key2 = arr[i].second;
			if (my2.count(key2) > 0) {
				cout << "NO"; return 0;
			}
			else {
				choose[i] = 1;
			//	my2[key2]++;
			}
		}
		else {
			my2[key]++;
			choose[i] = 0;	// 굳이 할 필욘 없다.
		}
	}
	cout << "YES" << '\n';
	rep(i, choose.size()) {
		if (choose[i] == 0) cout << arr[i].first << '\n';
		else cout << arr[i].second << '\n';
	}
	return 0;
}


#include <cstdio>
#include <queue>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <set>
#include <cmath>
#include <numeric> //accumulate
#include <stack>
#include <bitset>

//#include <unordered_set>//unordered_set

#define rep(i,a) for (int i = 0; i < (a); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define PI 3.14159265359;

	using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef const vector<int> cvi;
typedef vector<bool> vb;

//const ll INF = 1ull << 62;
const int INF = 987654321;
const int MOD = 1000000007;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	map<pair<string, string>, int> my;
	bool ok = true;
	rep(i, n) {
		string str1, str2; cin >> str1 >> str2;
		str1 = str1.substr(0, 3);
		str2 = str1.substr(0, 2) + str2[0];
		pair<string, string> key = mp(str1, str2);
		if (my.count(key) == 0) my[key] = i;
		else {
			ok = false;
		}
	}
	if (ok == false) cout << "NO";
	else {
		cout << "YES" << '\n';
		vs sol(n);
		string pre = "-1";
		map<pair<string, string>, int>::iterator it;
		it = my.begin();
		for (; it != my.end(); ++it) {
			string str1 = it->first.first;
			string str2 = it->first.second;
			int index = it->second;
			if (str1 == pre) {
				//cout << str2 << '\n';
				sol[index] = str2;
				pre = str2;
			}
			else {
				//cout << str1 << '\n';
				sol[index] = str1;
				pre = str1;
			}
		}
		rep(i, sol.size()) cout << sol[i] << '\n';
	}
	return 0;
}


#include <cstdio>
#include <queue>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <set>
#include <cmath>
#include <numeric> //accumulate
#include <stack>
#include <bitset>

//#include <unordered_set>//unordered_set

#define rep(i,a) for (int i = 0; i < (a); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define PI 3.14159265359;

	using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef const vector<int> cvi;
typedef vector<bool> vb;

//const ll INF = 1ull << 62;
const int INF = 987654321;
const int MOD = 1000000007;
// 앞이 같은 놈이 존재시 뒤를 선택한다.
// 이때 뒤도 같으면 망한다.
// 또한 모든 선택된 것은 달라야 한다.
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	vector<pair<string, string>> arr(n);
	rep(i, n) {
		string str1, str2; cin >> str1 >> str2;
		arr[i].first = str1.substr(0, 3);
		arr[i].second = str1.substr(0, 2) + str2[0];
	}
	map<string, int> my, my2;
	rep(i, n) my[arr[i].first]++;
	vi choose(n, 0);
	rep(i, n) if (my[arr[i].first] > 1) {
		choose[i] = 2;	// 두번째꺼 선택
		my2[arr[i].second]++;	// 선택된거 기록
	}
	map<string, int>::iterator it = my2.begin();
	for (; it != my2.end(); ++it) if (it->second > 1) {
		cout << "NO"; return 0;
	}

	// 먼저 첫번째 키가 중복되는 걸 처리한다.
	rep(i, n) {
		if (choose[i] == 2) continue;
		string key = arr[i].first;
		if (my2.count(key) > 0) {
			string key2 = arr[i].second;
			if (my2.count(key2) > 0) {
				cout << "NO"; return 0;
			}
			else {
				choose[i] = 2;
				my2[key2]++;
			}
		}
	}

	// 그다음 나머지들을 처리한다.
	rep(i, n) {
		if (choose[i] == 2) continue;
		string key = arr[i].first;
		if (my2.count(key) > 0) {
			string key2 = arr[i].second;
			if (my2.count(key2) > 0) {
				cout << "NO"; return 0;
			}
			else {
				choose[i] = 2;
				my2[key2]++;
			}
		}
		else {
			choose[i] = 1;
			my2[key]++;
		}
	}

	cout << "YES" << '\n';
	rep(i, choose.size()) {
		if (choose[i] == 1) cout << arr[i].first << '\n';
		else cout << arr[i].second << '\n';
	}
	return 0;
}


#include <cstdio>
#include <queue>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <set>
#include <cmath>
#include <numeric> //accumulate
#include <stack>
#include <bitset>

//#include <unordered_set>//unordered_set

#define rep(i,a) for (int i = 0; i < (a); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define PI 3.14159265359;

	using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef const vector<int> cvi;
typedef vector<bool> vb;

//const ll INF = 1ull << 62;
const int INF = 987654321;
const int MOD = 1000000007;
// 앞이 같은 놈이 존재시 뒤를 선택한다.
// 이때 뒤도 같으면 망한다.
// 또한 모든 선택된 것은 달라야 한다.
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	vector<pair<string, string>> arr(n);
	rep(i, n) {
		string str1, str2; cin >> str1 >> str2;
		arr[i].first = str1.substr(0, 3);
		arr[i].second = str1.substr(0, 2) + str2[0];
	}
	map<string, int> my, my2;
	rep(i, n) my[arr[i].first]++;
	vi choose(n, 0);
	rep(i, n) if (my[arr[i].first] > 1) {
		choose[i] = 1;	// 두번째꺼 선택
		my2[arr[i].second]++;	// 선택된거 기록
	}
	map<string, int>::iterator it = my2.begin();
	for (; it != my2.end(); ++it) if (it->second > 1) {
		cout << "NO"; return 0;
	}
	rep(i, n) {
		if (choose[i] == 1) continue;
		string key = arr[i].first;
		if (my2.count(key) > 0) {
			string key2 = arr[i].second;
			if (my2.count(key2) > 0) {
				cout << "NO"; return 0;
			}
			else {
				choose[i] = 1;
				my2[key2]++;
			}
		}
		else {
			my2[key]++;
			choose[i] = 0;	// 굳이 할 필욘 없다.
		}
	}
	cout << "YES" << '\n';
	rep(i, choose.size()) {
		if (choose[i] == 0) cout << arr[i].first << '\n';
		else cout << arr[i].second << '\n';
	}
	return 0;
}


#include <cstdio>
#include <queue>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <set>
#include <cmath>
#include <numeric> //accumulate
#include <stack>
#include <bitset>

//#include <unordered_set>//unordered_set

#define rep(i,a) for (int i = 0; i < (a); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define PI 3.14159265359;

using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef const vector<int> cvi;
typedef vector<bool> vb;

//const ll INF = 1ull << 62;
const int INF = 987654321;
const int MOD = 1000000007;

vvi adj;
vi sccId, dscv;
stack<int> st;
int sccCnt, vtxCnt;
int scc(int here) {
	int ret = dscv[here] = vtxCnt++;
	st.push(here);
	rep(i, adj[here].size()) {
		int there = adj[here][i];
		if (dscv[there] == -1)
			ret = min(ret, scc(there));
		else if (dscv[there] < dscv[here] && sccId[there] == -1)
			return min(ret, dscv[there]);
	}
	if (ret == dscv[here]) {
		while (true) {
			int t = st.top(); st.pop();
			sccId[t] = sccCnt;
			if (t == here) break;
		}
		++sccCnt;
	}
	return ret;
}
vi tarjanSCC() {
	sccId = dscv = vi(adj.size(), -1);
	sccCnt = vtxCnt = 0;
	rep(i, adj.size()) if (dscv[i] == -1) scc(i);
	return sccId;
}
set<int> ddSet;
void makeGraph(const vi& meetings) {
	int mtSize = meetings.size();
	adj.clear();
	adj.resize(mtSize * 2);
	// left 가 두개 이상 있는 놈들을 따로 기록
	map<int, int> mm;
	set<int> dd;
	for (int i = 0; i < mtSize; i += 2) {
		mm[meetings[i]]++;
	}
	for (int i = 0; i < mtSize; i += 2) {
		if (mm[meetings[i]] > 1)
			ddSet.insert(i);	// 왼쪽이 같은게 두개 이상인 것들을 기록
	}
	for (int i = 0; i < mtSize; i += 2) {
		if (dd.count(i) > 1) continue;	// 왼쪽은 무조건 선택 안함.
		int j = i + 1;
		adj[i * 2 + 1].push_back(j * 2);
		adj[j * 2 + 1].push_back(i * 2);
	}
	for (int i = 0; i < mtSize; ++i)
		for (int j = 0; j < i; ++j) {
			if (meetings[i] == meetings[j]) {
				adj[i * 2].push_back(j * 2 + 1);
				adj[j * 2].push_back(i * 2 + 1);
			}
		}
}
vi solve2SAT() {
	vi label = tarjanSCC();
	for (int i = 0; i < adj.size(); i += 2) if (label[i] == label[i + 1]) return vi();
	vpii order;
	for (int i = 0; i < adj.size(); ++i) order.push_back(mp(-label[i], i));
	sort(order.begin(), order.end());
	vi vbChoose(adj.size() / 2, -1); // 선택여부
	for (int i = 0; i < order.size(); ++i) {
		int node = order[i].second;
		int index = node / 2;
		if (ddSet.count(index)) {
			vbChoose[index] = false;
			vbChoose[index + 1] = true;
			continue;
		}
		if (vbChoose[index] != -1) continue;
		vbChoose[index] = !((node % 2) == 0);
	}
	return vbChoose;
}
vi solve(const vi& meetings) {
	makeGraph(meetings);
	vi ret = solve2SAT();
	return ret;
}
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	vi meetings(n * 2);
	map<string, int> my;
	map<int, string> myR;
	int index = 0;
	rep(i, n) {
		string str1, str2;	cin >> str1 >> str2;
		str1 = str1.substr(0, 3);
		str2 = str1.substr(0, 2) + str2[0];
		if (my.count(str1) == 0) {
			myR[index] = str1;  my[str1] = index++;
		}
		if (my.count(str2) == 0) {
			myR[index] = str2;	my[str2] = index++;
		}
		meetings[i * 2] = my[str1];
		meetings[i * 2 + 1] = my[str2];
	}
	vi value = solve(meetings);
	if (value.empty()) cout << "NO";
	else {
		cout << "YES" << '\n';
		for (int i = 0; i < 2 * n; i += 2) {
			if (value[i] == 1) {
				int idx = meetings[i];
				cout << myR[idx] << '\n';
			}
			else {
				int idx = meetings[i+1];
				cout << myR[idx] << '\n';
			}
		}
	}
	return 0;
}


#include <cstdio>
#include <queue>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <set>
#include <cmath>
#include <numeric> //accumulate
#include <stack>
#include <bitset>

//#include <unordered_set>//unordered_set

#define rep(i,a) for (int i = 0; i < (a); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define PI 3.14159265359;

using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef const vector<int> cvi;
typedef vector<bool> vb;

//const ll INF = 1ull << 62;
const int INF = 987654321;
const int MOD = 1000000007;

vvi adj;
vi sccId, dscv;
stack<int> st;
int sccCnt, vtxCnt;
int scc(int here) {
	int ret = dscv[here] = vtxCnt++;
	st.push(here);
	rep(i, adj[here].size()) {
		int there = adj[here][i];
		if (dscv[there] == -1)
			ret = min(ret, scc(there));
		else if (dscv[there] < dscv[here] && sccId[there] == -1)
			return min(ret, dscv[there]);
	}
	if (ret == dscv[here]) {
		while (true) {
			int t = st.top(); st.pop();
			sccId[t] = sccCnt;
			if (t == here) break;
		}
		++sccCnt;
	}
	return ret;
}
vi tarjanSCC() {
	sccId = dscv = vi(adj.size(), -1);
	sccCnt = vtxCnt = 0;
	rep(i, adj.size()) if (dscv[i] == -1) scc(i);
	return sccId;
}
set<int> ddSet;
void makeGraph(const vi& meetings) {
	int mtSize = meetings.size();
	adj.clear();
	adj.resize(mtSize * 2);
	// left 가 두개 이상 있는 놈들을 따로 기록
	map<int, int> mm;
	for (int i = 0; i < mtSize; i += 2) {
		mm[meetings[i]]++;
	}
	for (int i = 0; i < mtSize; i += 2) {
		if (mm[meetings[i]] > 1)
			ddSet.insert(i);	// 왼쪽이 같은게 두개 이상인 것들을 기록
	}

	set<int>::iterator it = ddSet.begin();
	for (; it != ddSet.end(); ++it) {
		int trueNode = *it * 2;
		int falseNode = *it * 2 + 1;
		adj[trueNode].push_back(falseNode);
	}
	for (int i = 0; i < mtSize; i += 2) {
		int j = i + 1;
		adj[i * 2 + 1].push_back(j * 2);
		adj[j * 2 + 1].push_back(i * 2);
	}
	for (int i = 0; i < mtSize; ++i)
		for (int j = 0; j < i; ++j) {
			if (meetings[i] == meetings[j]) {
				adj[i * 2].push_back(j * 2 + 1);
				adj[j * 2].push_back(i * 2 + 1);
			}
		}
}
vi solve2SAT() {
	vi label = tarjanSCC();
	for (int i = 0; i < adj.size(); i += 2) if (label[i] == label[i + 1]) return vi();
	vpii order;
	for (int i = 0; i < adj.size(); ++i) order.push_back(mp(-label[i], i));
	sort(order.begin(), order.end());
	vi vbChoose(adj.size() / 2, -1); // 선택여부
	for (int i = 0; i < order.size(); ++i) {
		int node = order[i].second;
		int index = node / 2;
		if (ddSet.count(index)) {
			vbChoose[index] = false;
			vbChoose[index + 1] = true;
			continue;
		}
		if (vbChoose[index] != -1) continue;
		vbChoose[index] = !((node % 2) == 0);
	}
	return vbChoose;
}
vi solve(const vi& meetings) {
	makeGraph(meetings);
	vi ret = solve2SAT();
	return ret;
}
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	vi meetings(n * 2);
	map<string, int> my;
	map<int, string> myR;
	int index = 0;
	rep(i, n) {
		string str1, str2;	cin >> str1 >> str2;
		str1 = str1.substr(0, 3);
		str2 = str1.substr(0, 2) + str2[0];
		if (my.count(str1) == 0) {
			myR[index] = str1;  my[str1] = index++;
		}
		if (my.count(str2) == 0) {
			myR[index] = str2;	my[str2] = index++;
		}
		meetings[i * 2] = my[str1];
		meetings[i * 2 + 1] = my[str2];
	}
	vi value = solve(meetings);
	if (value.empty()) cout << "NO";
	else {
		cout << "YES" << '\n';
		for (int i = 0; i < 2 * n; i += 2) {
			if (value[i] == 1) {
				int idx = meetings[i];
				cout << myR[idx] << '\n';
			}
			else {
				int idx = meetings[i+1];
				cout << myR[idx] << '\n';
			}
			/*	// 이렇게 해도 통과 됨.
			if (value[i + 1] == 1) {
				int idx = meetings[i + 1];
				cout << myR[idx] << '\n';
			}
			else {
				int idx = meetings[i];
				cout << myR[idx] << '\n';
			}
			*/
		}
	}
	return 0;
}


#include <cstdio>
#include <queue>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <set>
#include <cmath>
#include <numeric> //accumulate
#include <stack>
#include <bitset>

//#include <unordered_set>//unordered_set

#define rep(i,a) for (int i = 0; i < (a); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define PI 3.14159265359;

using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef const vector<int> cvi;
typedef vector<bool> vb;

//const ll INF = 1ull << 62;
const int INF = 987654321;
const int MOD = 1000000007;

vvi adj;
vi sccId, dscv;
stack<int> st;
int sccCnt, vtxCnt;
int scc(int here) {
	int ret = dscv[here] = vtxCnt++;
	st.push(here);
	rep(i, adj[here].size()) {
		int there = adj[here][i];
		if (dscv[there] == -1)
			ret = min(ret, scc(there));
		else if (dscv[there] < dscv[here] && sccId[there] == -1)
			return min(ret, dscv[there]);
	}
	if (ret == dscv[here]) {
		while (true) {
			int t = st.top(); st.pop();
			sccId[t] = sccCnt;
			if (t == here) break;
		}
		++sccCnt;
	}
	return ret;
}
vi tarjanSCC() {
	sccId = dscv = vi(adj.size(), -1);
	sccCnt = vtxCnt = 0;
	rep(i, adj.size()) if (dscv[i] == -1) scc(i);
	return sccId;
}
set<int> ddSet;
void makeGraph(const vi& meetings) {
	int mtSize = meetings.size();
	adj.clear();
	adj.resize(mtSize * 2);
	// left 가 두개 이상 있는 놈들을 따로 기록
	map<int, int> mm;
	for (int i = 0; i < mtSize; i += 2) {
		mm[meetings[i]]++;
	}
	for (int i = 0; i < mtSize; i += 2) {
		if (mm[meetings[i]] > 1)
			ddSet.insert(i);	// 왼쪽이 같은게 두개 이상인 것들을 기록
	}
	set<int>::iterator it = ddSet.begin();
	for (; it != ddSet.end(); ++it) {
		int fTrueNode = *it * 2;
		int fFalseNode = *it * 2 + 1;
		adj[fTrueNode].push_back(fFalseNode);

		int sTrueNode = (*it + 1) * 2;
		int sFalseNode = (*it + 1) * 2 + 1;
		adj[sFalseNode].push_back(sTrueNode);
	}

	for (int i = 0; i < mtSize; i += 2) {
		int j = i + 1;
		adj[i * 2 + 1].push_back(j * 2);
		adj[j * 2 + 1].push_back(i * 2);
	}
	for (int i = 0; i < mtSize; ++i)
		for (int j = 0; j < i; ++j) {
			if (meetings[i] == meetings[j]) {
				adj[i * 2].push_back(j * 2 + 1);
				adj[j * 2].push_back(i * 2 + 1);
			}
		}
}
vi solve2SAT() {
	vi label = tarjanSCC();
	for (int i = 0; i < adj.size(); i += 2) if (label[i] == label[i + 1]) return vi();
	vpii order;
	for (int i = 0; i < adj.size(); ++i) order.push_back(mp(-label[i], i));
	sort(order.begin(), order.end());
	vi vbChoose(adj.size() / 2, -1); // 선택여부
	for (int i = 0; i < order.size(); ++i) {
		int node = order[i].second;
		int index = node / 2;
		if (vbChoose[index] != -1) continue;
		vbChoose[index] = !((node % 2) == 0);
	}
	return vbChoose;
}
vi solve(const vi& meetings) {
	makeGraph(meetings);
	vi ret = solve2SAT();
	return ret;
}
int index;
map<string, int> my;
map<int, string> myR;
int getIndex(string& str) {
	if (my.count(str) == 0) {
		my[str] = index;
		myR[index] = str;
		index++;
	}
	return my[str];
}
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	vi meetings(n * 2);

	int index = 0;
	rep(i, n) {
		string str1, str2;	cin >> str1 >> str2;
		str1 = str1.substr(0, 3);
		str2 = str1.substr(0, 2) + str2[0];
		int idx1 = getIndex(str1);
		int idx2 = getIndex(str2);
		meetings[i * 2] = idx1;
		meetings[i * 2 + 1] = idx2;
	}
	vi value = solve(meetings);
	if (value.empty()) cout << "NO";
	else {
		cout << "YES" << '\n';
		for (int i = 0; i < 2 * n; i += 2) {
			if (value[i] == 1) {
				int idx = meetings[i];
				cout << myR[idx] << '\n';
			}
			else {
				int idx = meetings[i+1];
				cout << myR[idx] << '\n';
			}
		}
	}
	return 0;
}


#include <cstdio>
#include <queue>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <set>
#include <cmath>
#include <numeric> //accumulate
#include <stack>
#include <bitset>

//#include <unordered_set>//unordered_set

#define rep(i,a) for (int i = 0; i < (a); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define PI 3.14159265359;

using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef const vector<int> cvi;
typedef vector<bool> vb;

//const ll INF = 1ull << 62;
const int INF = 987654321;
const int MOD = 1000000007;

vvi adj;
vi sccId, dscv;
stack<int> st;
int sccCnt, vtxCnt;
int scc(int here) {
	int ret = dscv[here] = vtxCnt++;
	st.push(here);
	rep(i, adj[here].size()) {
		int there = adj[here][i];
		if (dscv[there] == -1)
			ret = min(ret, scc(there));
		else if (dscv[there] < dscv[here] && sccId[there] == -1)
			return min(ret, dscv[there]);
	}
	if (ret == dscv[here]) {
		while (true) {
			int t = st.top(); st.pop();
			sccId[t] = sccCnt;
			if (t == here) break;
		}
		++sccCnt;
	}
	return ret;
}
vi tarjanSCC() {
	sccId = dscv = vi(adj.size(), -1);
	sccCnt = vtxCnt = 0;
	rep(i, adj.size()) if (dscv[i] == -1) scc(i);
	return sccId;
}
set<int> ddSet;
void makeGraph(const vi& meetings) {
	int mtSize = meetings.size();
	adj.clear();
	adj.resize(mtSize * 2);
	// left 가 두개 이상 있는 놈들을 따로 기록
	map<int, int> mm;
	for (int i = 0; i < mtSize; i += 2) {
		mm[meetings[i]]++;
	}
	for (int i = 0; i < mtSize; i += 2) {
		if (mm[meetings[i]] > 1)
			ddSet.insert(i);	// 왼쪽이 같은게 두개 이상인 것들을 기록
	}

	multiset<int>::iterator it = ddSet.begin();
	for (; it != ddSet.end(); ++it) {
		int trueNode = *it * 2;
		int falseNode = *it * 2 + 1;
		adj[trueNode].push_back(falseNode);
	}
	for (int i = 0; i < mtSize; i += 2) {
		//if (ddSet.count(i)) continue;	// 왼쪽은 무조건 선택 안함.
		int j = i + 1;
		adj[i * 2 + 1].push_back(j * 2);
		adj[j * 2 + 1].push_back(i * 2);
	}
	for (int i = 0; i < mtSize; ++i)
		for (int j = 0; j < i; ++j) {
			if (meetings[i] == meetings[j]) {
				adj[i * 2].push_back(j * 2 + 1);
				adj[j * 2].push_back(i * 2 + 1);
			}
		}
}
vi solve2SAT() {
	vi label = tarjanSCC();
	for (int i = 0; i < adj.size(); i += 2) if (label[i] == label[i + 1]) return vi();
	vpii order;
	for (int i = 0; i < adj.size(); ++i) order.push_back(mp(-label[i], i));
	sort(order.begin(), order.end());
	vi vbChoose(adj.size() / 2, -1); // 선택여부
	for (int i = 0; i < order.size(); ++i) {
		int node = order[i].second;
		int index = node / 2;
		if (ddSet.count(index)) {
			vbChoose[index] = false;
			vbChoose[index + 1] = true;
			continue;
		}
		if (vbChoose[index] != -1) continue;
		vbChoose[index] = !((node % 2) == 0);
	}
	return vbChoose;
}
vi solve(const vi& meetings) {
	makeGraph(meetings);
	vi ret = solve2SAT();
	return ret;
}
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	vi meetings(n * 2);
	map<string, int> my;
	map<int, string> myR;
	int index = 0;
	rep(i, n) {
		string str1, str2;	cin >> str1 >> str2;
		str1 = str1.substr(0, 3);
		str2 = str1.substr(0, 2) + str2[0];
		if (my.count(str1) == 0) {
			myR[index] = str1;  my[str1] = index++;
		}
		if (my.count(str2) == 0) {
			myR[index] = str2;	my[str2] = index++;
		}
		meetings[i * 2] = my[str1];
		meetings[i * 2 + 1] = my[str2];
	}
	vi value = solve(meetings);
	if (value.empty()) cout << "NO";
	else {
		cout << "YES" << '\n';
		for (int i = 0; i < 2 * n; i += 2) {
			if (value[i + 1] == 1) {
				int idx = meetings[i + 1];
				cout << myR[idx] << '\n';
			}
			else {
				int idx = meetings[i];
				cout << myR[idx] << '\n';
			}
			/*
			if (value[i] == 1) {
				int idx = meetings[i];
				cout << myR[idx] << '\n';
			}
			else {
				int idx = meetings[i+1];
				cout << myR[idx] << '\n';
			}*/
		}
	}
	return 0;
}


#include <cstdio>
#include <queue>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <set>
#include <cmath>
#include <numeric> //accumulate
#include <stack>
#include <bitset>

//#include <unordered_set>//unordered_set

#define rep(i,a) for (int i = 0; i < (a); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define PI 3.14159265359;

using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef const vector<int> cvi;
typedef vector<bool> vb;

//const ll INF = 1ull << 62;
const int INF = 987654321;
const int MOD = 1000000007;

// 앞이 같은 놈이 존재시 뒤를 선택한다.
// 이때 뒤도 같으면 망한다.
// 또한 모든 선택된 것은 달라야 한다.

map<string, int> my, my2, my3;
vi choose;
vector<pair<string, string>> arr;
// 현 노드는 오른쪽 것만 선택해야 한다.
int dfs(int node) {
	if (choose[node] != 0) return 0;	// 이미 처리된거면 이상무
	string keyL = arr[node].first, keyR = arr[node].second;
	if (my2.count(keyL) > 0) {			// 연결된 놈이 있으면 keyR 을 선택해야 한다.
		if (my2.count(keyR) > 0)
			return -1;	// 선택 불가능한 경우
		my2[keyR]++;
		choose[node] = 2;	// 오른쪽이 선택된다.
		int nextNode = my3[keyR];	// keyR 을 왼쪽 키로 갖는 노드를 찾는다.
		if (nextNode == -1) {
			cout << "OMG";
			return 0;
		}
		return dfs(nextNode);
	}
	// 아무 노드에도 연결 된 것이 아니면 일단 무시한다.
	return 0;	// 이건 첫 호출에만 타는 루틴이 된다.
}
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	arr.resize(n);
	rep(i, n) {
		string str1, str2; cin >> str1 >> str2;
		arr[i].first = str1.substr(0, 3);
		arr[i].second = str1.substr(0, 2) + str2[0];
	}
	rep(i, n) my[arr[i].first]++;
	choose.resize(n, 0);
	rep(i, n) if (my[arr[i].first] > 1) {
		choose[i] = 2;	// 두번째꺼 선택
		my2[arr[i].second]++;	// 선택된거 기록
	}
	map<string, int>::iterator it = my2.begin();
	for (; it != my2.end(); ++it) if (it->second > 1) {
		cout << "NO"; return 0;
	}
	// left 가 유일한거 인덱스 기록
	rep(i, n) if (choose[i] != 2) my3[arr[i].first] = i;

	// 첫번째 키가 중복될 시 두번째 키를 선택하도록 한다. 그리고 dfs 탄다.
	rep(i, n) {
		if (choose[i] == 2) continue;
		string keyL = arr[i].first;
		if (my2.count(keyL) > 0) {	// 첫번째 키가 중복인 놈들로 dfs
			int node = my3[keyL];
			int judge = dfs(node);
			if (judge == -1) {
				cout << "NO"; return 0;
			}
		}
	}

	// 그다음 나머지들을 처리한다
	cout << "YES" << '\n';
	rep(i, choose.size()) {
		if (choose[i] == 0 || choose[i] == 1)
			cout << arr[i].first << '\n';
		else cout << arr[i].second << '\n';
	}
	return 0;
}


#include <cstdio>
#include <queue>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <set>
#include <cmath>
#include <numeric> //accumulate
#include <stack>
#include <bitset>

//#include <unordered_set>//unordered_set

#define rep(i,a) for (int i = 0; i < (a); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define PI 3.14159265359;

using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef const vector<int> cvi;
typedef vector<bool> vb;

//const ll INF = 1ull << 62;
const int INF = 987654321;
const int MOD = 1000000007;

vvi adj;
vi sccId, dscv;
stack<int> st;
int sccCnt, vtxCnt;
int scc(int here) {
	int ret = dscv[here] = vtxCnt++;
	st.push(here);
	rep(i, adj[here].size()) {
		int there = adj[here][i];
		if (dscv[there] == -1)
			ret = min(ret, scc(there));
		else if (dscv[there] < dscv[here] && sccId[there] == -1)
			return min(ret, dscv[there]);
	}
	if (ret == dscv[here]) {
		while (true) {
			int t = st.top(); st.pop();
			sccId[t] = sccCnt;
			if (t == here) break;
		}
		++sccCnt;
	}
	return ret;
}
vi tarjanSCC() {
	sccId = dscv = vi(adj.size(), -1);
	sccCnt = vtxCnt = 0;
	rep(i, adj.size()) if (dscv[i] == -1) scc(i);
	return sccId;
}
set<int> ddSet;
set<int> ddSet2;
void makeGraph(const vi& meetings) {
	int mtSize = meetings.size();
	adj.clear();
	adj.resize(mtSize * 2);
	// left 가 두개 이상 있는 놈들을 따로 기록
	map<int, int> mm;
	for (int i = 0; i < mtSize; i += 2) {
		mm[meetings[i]]++;
	}
	/*
	for (int i = 0; i < mtSize; i += 2) {
		if (mm[meetings[i]] > 1)
			ddSet.insert(i);	// 왼쪽이 같은게 두개 이상인 것들을 기록
	}
	set<int>::iterator it = ddSet.begin();
	for (; it != ddSet.end(); ++it) {
		int trueNode = *it * 2;
		int falseNode = *it * 2 + 1;
		adj[trueNode].push_back(falseNode);
	}
	*/
	for (int i = 0; i < mtSize; i += 2) {
		if (mm[meetings[i]] > 1)
			ddSet2.insert(i + 1);	// 오른쪽만 기록
	}
	set<int>::iterator it2 = ddSet2.begin();
	for (; it2 != ddSet2.end(); ++it2) {
		int falseNode = *it2 * 2 + 1;
		int trueNode = *it2 * 2;
		adj[falseNode].push_back(trueNode);
	}

	for (int i = 0; i < mtSize; i += 2) {
		int j = i + 1;
		adj[i * 2 + 1].push_back(j * 2);
		adj[j * 2 + 1].push_back(i * 2);
	}
	for (int i = 0; i < mtSize; ++i)
		for (int j = 0; j < i; ++j) {
			if (meetings[i] == meetings[j]) {
				adj[i * 2].push_back(j * 2 + 1);
				adj[j * 2].push_back(i * 2 + 1);
			}
		}
}
vi solve2SAT() {
	vi label = tarjanSCC();
	for (int i = 0; i < adj.size(); i += 2) if (label[i] == label[i + 1]) return vi();
	vpii order;
	for (int i = 0; i < adj.size(); ++i) order.push_back(mp(-label[i], i));
	sort(order.begin(), order.end());
	vi vbChoose(adj.size() / 2, -1); // 선택여부
	for (int i = 0; i < order.size(); ++i) {
		int node = order[i].second;
		int index = node / 2;
		if (vbChoose[index] != -1) continue;
		vbChoose[index] = !((node % 2) == 0);
	}
	return vbChoose;
}
vi solve(const vi& meetings) {
	makeGraph(meetings);
	vi ret = solve2SAT();
	return ret;
}
int index;
map<string, int> my;
map<int, string> myR;
int getIndex(string& str) {
	if (my.count(str) == 0) {
		my[str] = index;
		myR[index] = str;
		index++;
	}
	return my[str];
}
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	vi meetings(n * 2);

	int index = 0;
	rep(i, n) {
		string str1, str2;	cin >> str1 >> str2;
		str1 = str1.substr(0, 3);
		str2 = str1.substr(0, 2) + str2[0];
		int idx1 = getIndex(str1);
		int idx2 = getIndex(str2);
		meetings[i * 2] = idx1;
		meetings[i * 2 + 1] = idx2;
	}
	vi value = solve(meetings);
	if (value.empty()) cout << "NO";
	else {
		cout << "YES" << '\n';
		for (int i = 0; i < 2 * n; i += 2) {
			if (value[i] == 1) {
				int idx = meetings[i];
				cout << myR[idx] << '\n';
			}
			else {
				int idx = meetings[i+1];
				cout << myR[idx] << '\n';
			}
		}
	}
	return 0;
}


#include <cstdio>
#include <queue>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <set>
#include <cmath>
#include <numeric> //accumulate
#include <stack>
#include <bitset>

//#include <unordered_set>//unordered_set

#define rep(i,a) for (int i = 0; i < (a); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define PI 3.14159265359;

using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef const vector<int> cvi;
typedef vector<bool> vb;

//const ll INF = 1ull << 62;
const int INF = 987654321;
const int MOD = 1000000007;

vvi adj;
vi sccId, dscv;
stack<int> st;
int sccCnt, vtxCnt;
int scc(int here) {
	int ret = dscv[here] = vtxCnt++;
	st.push(here);
	rep(i, adj[here].size()) {
		int there = adj[here][i];
		if (dscv[there] == -1)
			ret = min(ret, scc(there));
		else if (dscv[there] < dscv[here] && sccId[there] == -1)
			return min(ret, dscv[there]);
	}
	if (ret == dscv[here]) {
		while (true) {
			int t = st.top(); st.pop();
			sccId[t] = sccCnt;
			if (t == here) break;
		}
		++sccCnt;
	}
	return ret;
}
vi tarjanSCC() {
	sccId = dscv = vi(adj.size(), -1);
	sccCnt = vtxCnt = 0;
	rep(i, adj.size()) if (dscv[i] == -1) scc(i);
	return sccId;
}
set<int> ddSet;
void makeGraph(const vi& meetings) {
	int mtSize = meetings.size();
	adj.clear();
	adj.resize(mtSize * 2);
	// left 가 두개 이상 있는 놈들을 따로 기록
	map<int, int> mm;
	for (int i = 0; i < mtSize; i += 2) {
		mm[meetings[i]]++;
	}
	for (int i = 0; i < mtSize; i += 2) {
		if (mm[meetings[i]] > 1)
			ddSet.insert(i);	// 왼쪽이 같은게 두개 이상인 것들을 기록
	}

	set<int>::iterator it = ddSet.begin();
	for (; it != ddSet.end(); ++it) {
		int trueNode = *it * 2;
		int falseNode = *it * 2 + 1;
		adj[trueNode].push_back(falseNode);
	}
	for (int i = 0; i < mtSize; i += 2) {
		int j = i + 1;
		adj[i * 2 + 1].push_back(j * 2);
		adj[j * 2 + 1].push_back(i * 2);
	}
	for (int i = 0; i < mtSize; ++i)
		for (int j = 0; j < i; ++j) {
			if (meetings[i] == meetings[j]) {
				adj[i * 2].push_back(j * 2 + 1);
				adj[j * 2].push_back(i * 2 + 1);
			}
		}
}
vi solve2SAT() {
	vi label = tarjanSCC();
	for (int i = 0; i < adj.size(); i += 2) if (label[i] == label[i + 1]) return vi();
	vpii order;
	for (int i = 0; i < adj.size(); ++i) order.push_back(mp(-label[i], i));
	sort(order.begin(), order.end());
	vi vbChoose(adj.size() / 2, -1); // 선택여부
	for (int i = 0; i < order.size(); ++i) {
		int node = order[i].second;
		int index = node / 2;
		//if (ddSet.count(index)) {
		//	vbChoose[index] = false;
		//	vbChoose[index + 1] = true;
		//	continue;
		//}
		if (vbChoose[index] != -1) continue;
		vbChoose[index] = !((node % 2) == 0);
	}
	return vbChoose;
}
vi solve(const vi& meetings) {
	makeGraph(meetings);
	vi ret = solve2SAT();
	return ret;
}
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	vi meetings(n * 2);
	map<string, int> my;
	map<int, string> myR;
	int index = 0;
	rep(i, n) {
		string str1, str2;	cin >> str1 >> str2;
		str1 = str1.substr(0, 3);
		str2 = str1.substr(0, 2) + str2[0];
		if (my.count(str1) == 0) {
			myR[index] = str1;  my[str1] = index++;
		}
		if (my.count(str2) == 0) {
			myR[index] = str2;	my[str2] = index++;
		}
		meetings[i * 2] = my[str1];
		meetings[i * 2 + 1] = my[str2];
	}
	vi value = solve(meetings);
	if (value.empty()) cout << "NO";
	else {
		cout << "YES" << '\n';
		for (int i = 0; i < 2 * n; i += 2) {
			/*
			if (value[i] == 1) {
				int idx = meetings[i];
				cout << myR[idx] << '\n';
			}
			else {
				int idx = meetings[i+1];
				cout << myR[idx] << '\n';
			}
			*/
				// 이렇게 해도 통과 됨.
			if (value[i + 1] == 1) {
				int idx = meetings[i + 1];
				cout << myR[idx] << '\n';
			}
			else {
				int idx = meetings[i];
				cout << myR[idx] << '\n';
			}

		}
	}
	return 0;
}


#include <cstdio>
#include <queue>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <set>
#include <cmath>
#include <numeric> //accumulate
#include <stack>
#include <bitset>

//#include <unordered_set>//unordered_set

#define rep(i,a) for (int i = 0; i < (a); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define PI 3.14159265359;

using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef const vector<int> cvi;
typedef vector<bool> vb;

//const ll INF = 1ull << 62;
const int INF = 987654321;
const int MOD = 1000000007;

vvi adj;
vi sccId, dscv;
stack<int> st;
int sccCnt, vtxCnt;
int scc(int here) {
	int ret = dscv[here] = vtxCnt++;
	st.push(here);
	rep(i, adj[here].size()) {
		int there = adj[here][i];
		if (dscv[there] == -1)
			ret = min(ret, scc(there));
		else if (dscv[there] < dscv[here] && sccId[there] == -1)
			return min(ret, dscv[there]);
	}
	if (ret == dscv[here]) {
		while (true) {
			int t = st.top(); st.pop();
			sccId[t] = sccCnt;
			if (t == here) break;
		}
		++sccCnt;
	}
	return ret;
}
vi tarjanSCC() {
	sccId = dscv = vi(adj.size(), -1);
	sccCnt = vtxCnt = 0;
	rep(i, adj.size()) if (dscv[i] == -1) scc(i);
	return sccId;
}
set<int> ddSet;
set<int> ddSet2;
void makeGraph(const vi& meetings) {
	int mtSize = meetings.size();
	adj.clear();
	adj.resize(mtSize * 2);
	// left 가 두개 이상 있는 놈들을 따로 기록
	map<int, int> mm;
	for (int i = 0; i < mtSize; i += 2) {
		mm[meetings[i]]++;
	}
	/*
	for (int i = 0; i < mtSize; i += 2) {
		if (mm[meetings[i]] > 1)
			ddSet.insert(i);	// 왼쪽이 같은게 두개 이상인 것들을 기록
	}
	set<int>::iterator it = ddSet.begin();
	for (; it != ddSet.end(); ++it) {
		int trueNode = *it * 2;
		int falseNode = *it * 2 + 1;
		adj[trueNode].push_back(falseNode);
	}
	*/
	for (int i = 0; i < mtSize; i += 2) {
		if (mm[meetings[i]] > 1)
			ddSet2.insert(i + 1);	// 오른쪽만 기록
	}
	set<int>::iterator it2 = ddSet2.begin();
	for (; it2 != ddSet2.end(); ++it2) {
		int falseNode = *it2 * 2 + 1;
		int trueNode = *it2 * 2;
		adj[falseNode].push_back(trueNode);
	}

	for (int i = 0; i < mtSize; i += 2) {
		int j = i + 1;
		adj[i * 2 + 1].push_back(j * 2);
		adj[j * 2 + 1].push_back(i * 2);
	}
	for (int i = 0; i < mtSize; ++i)
		for (int j = 0; j < i; ++j) {
			if (meetings[i] == meetings[j]) {
				adj[i * 2].push_back(j * 2 + 1);
				adj[j * 2].push_back(i * 2 + 1);
			}
		}
}
vi solve2SAT() {
	vi label = tarjanSCC();
	for (int i = 0; i < adj.size(); i += 2) if (label[i] == label[i + 1]) return vi();
	vpii order;
	for (int i = 0; i < adj.size(); ++i) order.push_back(mp(-label[i], i));
	sort(order.begin(), order.end());
	vi vbChoose(adj.size() / 2, -1); // 선택여부
	for (int i = 0; i < order.size(); ++i) {
		int node = order[i].second;
		int index = node / 2;
		if (vbChoose[index] != -1) continue;
		vbChoose[index] = !((node % 2) == 0);
	}
	return vbChoose;
}
vi solve(const vi& meetings) {
	makeGraph(meetings);
	vi ret = solve2SAT();
	return ret;
}
int index;
map<string, int> my;
map<int, string> myR;
int getIndex(string& str) {
	if (my.count(str) == 0) {
		my[str] = index;
		myR[index] = str;
		index++;
	}
	return my[str];
}
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	vi meetings(n * 2);

	int index = 0;
	rep(i, n) {
		string str1, str2;	cin >> str1 >> str2;
		str1 = str1.substr(0, 3);
		str2 = str1.substr(0, 2) + str2[0];
		int idx1 = getIndex(str1);
		int idx2 = getIndex(str2);
		meetings[i * 2] = idx1;
		meetings[i * 2 + 1] = idx2;
	}
	vi value = solve(meetings);
	if (value.empty()) cout << "NO";
	else {
		cout << "YES" << '\n';
		for (int i = 0; i < 2 * n; i += 2) {
			if (value[i] == 1 && value[i+1] == 0) {
				int idx = meetings[i];
				cout << myR[idx] << '\n';
			}
			else {
				int idx = meetings[i+1];
				cout << myR[idx] << '\n';
			}
		}
	}
	return 0;
}


#include <cstdio>
#include <queue>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <set>
#include <cmath>
#include <numeric> //accumulate
#include <stack>
#include <bitset>

//#include <unordered_set>//unordered_set

#define rep(i,a) for (int i = 0; i < (a); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define PI 3.14159265359;

using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef const vector<int> cvi;
typedef vector<bool> vb;

//const ll INF = 1ull << 62;
const int INF = 987654321;
const int MOD = 1000000007;

const int N = 1010, M = 2020;
int n, m; bool adj[N][M];
vi aM, bM; vb vstd;
bool dfs(int a) {
	if (vstd[a]) return false;
	vstd[a] = true;
	for (int b = 0; b < m; ++b)
		if (adj[a][b])
			if (bM[b] == -1 || dfs(bM[b])) {
				aM[a] = b; bM[b] = a; return true;
			}
	return false;
}
int bpttM() {
	aM = vi(n, -1); bM = vi(m, -1);
	int size = 0;
	for (int start = 0; start < n; ++start) {
		vstd = vb(n, false);
		if (dfs(start)) ++size;
	}
	return size;
}
string arr[N][2];
map<string, int> cntF;
map<string, int> keyS;
map<int, string> valS;
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n; m = n * 2;
	int idx = 0;
	rep(i, n) {
		string str1, str2; cin >> str1 >> str2;
		arr[i][0] = string{ str1[0], str1[1], str1[2] };
		arr[i][1] = string{ str1[0], str1[1], str2[0] };
		cntF[arr[i][0]]++;
		if (keyS.count(arr[i][0]) == 0)
			keyS[arr[i][0]] = idx, valS[idx] = arr[i][0], idx++;
		if (keyS.count(arr[i][1]) == 0)
			keyS[arr[i][1]] = idx, valS[idx] = arr[i][1], idx++;
	}
	rep(i, n) {
		int k1 = keyS[arr[i][0]], k2 = keyS[arr[i][1]];
		//if (cntF.count(arr[i][0]) == 1) // map 에선 count를 셀땐 최대 1...
		if (cntF[arr[i][0]] == 1)
			adj[i][k1] = 1;
		adj[i][k2] = 1;
	}
	int sz = bpttM();
	if (sz != n) puts("NO");
	else {
		puts("YES");
		rep(i, aM.size()) {
			int b = aM[i];
			string str = valS[b];
			cout << str << '\n';
		}
	}
	return 0;
}


#include <cstdio>
#include <queue>
#include <iostream>
#include <string>
#include <vector>
#include <fstream>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <map>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <set>
#include <cmath>
#include <numeric> //accumulate
#include <stack>
#include <bitset>

//#include <unordered_set>//unordered_set

#define rep(i,a) for (int i = 0; i < (a); ++i)
#define rep2(i,a,b) for (int i = (a); i < (b); ++i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define PI 3.14159265359;

using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef const vector<int> cvi;
typedef vector<bool> vb;

//const ll INF = 1ull << 62;
const int INF = 987654321;
const int MOD = 1000000007;

vvi adj;
vi sccId, dscv;
stack<int> st;
int sccCnt, vtxCnt;
int scc(int here) {
	int ret = dscv[here] = vtxCnt++;
	st.push(here);
	rep(i, adj[here].size()) {
		int there = adj[here][i];
		if (dscv[there] == -1)
			ret = min(ret, scc(there));
		else if (dscv[there] < dscv[here] && sccId[there] == -1)
			return min(ret, dscv[there]);
	}
	if (ret == dscv[here]) {
		while (true) {
			int t = st.top(); st.pop();
			sccId[t] = sccCnt;
			if (t == here) break;
		}
		++sccCnt;
	}
	return ret;
}
vi tarjanSCC() {
	sccId = dscv = vi(adj.size(), -1);
	sccCnt = vtxCnt = 0;
	rep(i, adj.size()) if (dscv[i] == -1) scc(i);
	return sccId;
}
set<int> ddSet;
void makeGraph(const vi& meetings) {
	int mtSize = meetings.size();
	adj.clear();
	adj.resize(mtSize * 2);
	// left 가 두개 이상 있는 놈들을 따로 기록
	map<int, int> mm;
	for (int i = 0; i < mtSize; i += 2) {
		mm[meetings[i]]++;
	}
	for (int i = 0; i < mtSize; i += 2) {
		if (mm[meetings[i]] > 1)
			ddSet.insert(i);	// 왼쪽이 같은게 두개 이상인 것들을 기록
	}

	set<int>::iterator it = ddSet.begin();
	for (; it != ddSet.end(); ++it) {
		int trueNode = *it * 2;
		int falseNode = *it * 2 + 1;
		adj[trueNode].push_back(falseNode);
	}
	for (int i = 0; i < mtSize; i += 2) {
		int j = i + 1;
		adj[i * 2 + 1].push_back(j * 2);
		adj[j * 2 + 1].push_back(i * 2);
	}
	for (int i = 0; i < mtSize; ++i)
		for (int j = 0; j < i; ++j) {
			if (meetings[i] == meetings[j]) {
				adj[i * 2].push_back(j * 2 + 1);
				adj[j * 2].push_back(i * 2 + 1);
			}
		}
}
vi solve2SAT() {
	vi label = tarjanSCC();
	for (int i = 0; i < adj.size(); i += 2) if (label[i] == label[i + 1]) return vi();
	vpii order;
	for (int i = 0; i < adj.size(); ++i) order.push_back(mp(-label[i], i));
	sort(order.begin(), order.end());
	vi vbChoose(adj.size() / 2, -1); // 선택여부
	for (int i = 0; i < order.size(); ++i) {
		int node = order[i].second;
		int index = node / 2;
		//if (ddSet.count(index)) {
		//	vbChoose[index] = false;
		//	vbChoose[index + 1] = true;
		//	continue;
		//}
		if (vbChoose[index] != -1) continue;
		vbChoose[index] = !((node % 2) == 0);
	}
	return vbChoose;
}
vi solve(const vi& meetings) {
	makeGraph(meetings);
	vi ret = solve2SAT();
	return ret;
}
int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin >> n;
	vi meetings(n * 2);
	map<string, int> my;
	map<int, string> myR;
	int index = 0;
	rep(i, n) {
		string str1, str2;	cin >> str1 >> str2;
		str1 = str1.substr(0, 3);
		str2 = str1.substr(0, 2) + str2[0];
		if (my.count(str1) == 0) {
			myR[index] = str1;  my[str1] = index++;
		}
		if (my.count(str2) == 0) {
			myR[index] = str2;	my[str2] = index++;
		}
		meetings[i * 2] = my[str1];
		meetings[i * 2 + 1] = my[str2];
	}
	vi value = solve(meetings);
	if (value.empty()) cout << "NO";
	else {
		cout << "YES" << '\n';
		for (int i = 0; i < 2 * n; i += 2) {
			if (value[i] == 1) {
				int idx = meetings[i];
				cout << myR[idx] << '\n';
			}
			else {
				int idx = meetings[i+1];
				cout << myR[idx] << '\n';
			}
			/*	// 이렇게 해도 통과 됨.
			if (value[i + 1] == 1) {
				int idx = meetings[i + 1];
				cout << myR[idx] << '\n';
			}
			else {
				int idx = meetings[i];
				cout << myR[idx] << '\n';
			}
			*/
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))
#define bitcount    __builtin_popcountll
#define mod 1000000007
#define N 1000009
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss(s) cin>>s;
#define si(x)  scanf("%d",&x);
#define sl(x)  cin>>x;
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define ll long long
ll power(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
string a,b,c;
int q,n,t;
int arr[N];
vector<string> vs;
set<string> s;
map<string,vector<pair<int,char> > > m;
int as[N];

int main(){
//fast                          //uncomment on submission
cin>>n;
string an[1000];
for(int i = 0;i<n;i++){
	cin >> a >>  b;
	string j = a.substr(0,3);
	m[j].pb(mp(i,char(b[0])));
	j+=char(b[0]);
	vs.pb(j);
	if(s.find(j)!=s.end()){
		cout << "NO";
		exit(0);

	}
	s.insert(j);
}
set<string> col;
for(auto k:m){
	auto s = k.S;
	if(s.size() == 1)continue;
	for(auto i:s){
		col.insert((k.F).substr(0,2) + i.S);
		an[i.F] = (k.F).substr(0,2) + i.S;
		as[i.F] = 1;
	}

}
for(int i =0;i<n;i++){

	if(!as[i]){
		if(col.find(vs[i].substr(0,3)) == col.end())
		{an[i] =  vs[i].substr(0,3);col.insert(vs[i].substr(0,3));}
		else{
				an[i] =  vs[i].substr(0,2) + char(vs[i][4]);col.insert(vs[i].substr(0,2) + char(vs[i][4]));
		}
	}

}
if(col.size()!= n){
	cout << "NO";
}
else {
	cout <<"YES\n";
	for(int i =0;i<n;i++)
			cout<<an[i]<<"\n";
}

}


#include <bits/stdc++.h>
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))
#define bitcount    __builtin_popcountll
#define mod 1000000007
#define N 1000009
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss(s) cin>>s;
#define si(x)  scanf("%d",&x);
#define sl(x)  cin>>x;
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define ll long long
ll power(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
string a,b,c;
int q,n,t;
int arr[N];
vector<string> vs;
set<string> s;
int main(){
//fast                          //uncomment on submission
cin>>n;
for(int i = 1;i<=n;i++){
	cin >> a >>  b;
	string j = a.substr(0,3);
	j+=char(b[0]);
	vs.pb(j);
	if(s.find(j)!=s.end()){
		cout << "NO";
		exit(0);

	}
	s.insert(j);
}
vector<int> ans;
set<string> k;
cout << "YES\n";
for(int i = 0;i<n;i++){
	string j = vs[i].substr(0,2) +char(vs[i][3]);
	if(k.find(j) == k.end()){
		k.insert(j);
		cout<<j;
		j[2] = vs[i][2];
		k.insert(j);
	}
	else{
		j[2] = vs[i][2];
		if(k.find(j) != k.end()){
			cout << "NO";
			exit(0);
		}
		k.insert(j);
		cout << j;
	}

	cout << "\n";

}

}


#include <bits/stdc++.h>
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))
#define bitcount    __builtin_popcountll
#define mod 1000000007
#define N 1000009
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss(s) cin>>s;
#define si(x)  scanf("%d",&x);
#define sl(x)  cin>>x;
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define ll long long
ll power(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
string a,b,c;
int q,n,t;
int arr[N];
vector<string> vs;
set<string> s;
map<string,vector<pair<int,char> > > m;
int as[N];

int main(){
//fast                          //uncomment on submission
cin>>n;
string an[1000];
for(int i = 0;i<n;i++){
	cin >> a >>  b;
	string j = a.substr(0,3);
	m[j].pb(mp(i,char(b[0])));
	j+=char(b[0]);
	vs.pb(j);
	if(s.find(j)!=s.end()){
		cout << "NO";
		exit(0);

	}
	s.insert(j);
}
set<string> col;
for(auto k:m){
	auto s = k.S;
	if(s.size() == 1)continue;
	for(auto i:s){
		col.insert((k.F).substr(0,2) + i.S);
		an[i.F] = (k.F).substr(0,2) + i.S;
		as[i.F] = 1;
	}

}
for(int i =0;i<n;i++){

	if(!as[i]){
		if(col.find(vs[i].substr(0,3)) == col.end())
		{an[i] =  vs[i].substr(0,3);col.insert(vs[i].substr(0,3));}
		else{
				an[i] =  vs[i].substr(0,2) + char(vs[i][3]);col.insert(vs[i].substr(0,2) + char(vs[i][3]));
		}
	}

}
if(col.size()!= n){
	cout << "NO";
}
else {
	cout <<"YES\n";
	for(int i =0;i<n;i++)
			cout<<an[i]<<"\n";
}

}


#include <bits/stdc++.h>
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))
#define bitcount    __builtin_popcountll
#define mod 1000000007
#define N 1000009
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss(s) cin>>s;
#define si(x)  scanf("%d",&x);
#define sl(x)  cin>>x;
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define ll long long
ll power(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
string a,b,c;
int q,n,t;
int arr[N];
vector<string> vs;
set<string> s;
int main(){
//fast                          //uncomment on submission
cin>>n;
for(int i = 1;i<=n;i++){
	cin >> a >>  b;
	string j = a.substr(0,3);
	j+=char(b[0]);
	vs.pb(j);
	if(s.find(j)!=s.end()){
		cout << "NO";
		exit(0);

	}
	s.insert(j);
}
vector<int> ans;
cout << "YES\n";
for(int i = 0;i<n;i++){
	cout<<vs[i][0]<<vs[i][1]<<vs[i][3];
	cout << "\n";

}

}


#include <bits/stdc++.h>
using namespace std;
#define mem(x,y) memset(x,y,sizeof(x))
#define bitcount    __builtin_popcountll
#define mod 1000000007
#define N 1000009
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss(s) cin>>s;
#define si(x)  scanf("%d",&x);
#define sl(x)  cin>>x;
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define S second
#define F first
#define ll long long
ll power(ll a,ll b) {ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
string a,b,c;
int q,n,t;
int arr[N];
vector<string> vs;
set<string> s;
map<string,vector<pair<int,char> > > m;
int as[N];

int main(){
//fast                          //uncomment on submission
cin>>n;
string an[1000];
for(int i = 0;i<n;i++){
	cin >> a >>  b;
	string j = a.substr(0,3);
	m[j].pb(mp(i,char(b[0])));
	j+=char(b[0]);
	vs.pb(j);
	if(s.find(j)!=s.end()){
		cout << "NO";
		exit(0);

	}
	s.insert(j);
}
set<string> col;
for(auto k:m){
	auto s = k.S;
	if(s.size() == 1)continue;
	for(auto i:s){
		col.insert((k.F).substr(0,2) + i.S);
		an[i.F] = (k.F).substr(0,2) + i.S;
		as[i.F] = 1;
	}

}
for(int i =0;i<n;i++){

	if(!as[i]){
		if(col.find(vs[i].substr(0,2) + char(vs[i][3])) != col.end())
		{an[i] =  vs[i].substr(0,3);col.insert(vs[i].substr(0,3));}
		else{
				an[i] =  vs[i].substr(0,2) + char(vs[i][3]);col.insert(vs[i].substr(0,2) + char(vs[i][3]));
		}
	}

}
if(col.size()!= n){
	cout << "NO";
}
else {
	cout <<"YES\n";
	for(int i =0;i<n;i++)
			cout<<an[i]<<"\n";
}

}


#include <iostream>
#include <map>
#define Nmax 1005
using namespace std;
int n,viz[Nmax],nr[Nmax];
map<string,int>mp;
string s1,s2,a[Nmax],b[Nmax];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>s1>>s2;
        a[i]="";b[i]="";
        a[i].push_back(s1[0]);a[i].push_back(s1[1]);a[i].push_back(s1[2]);
        b[i].push_back(s1[0]);b[i].push_back(s1[1]);b[i].push_back(s2[0]);
    }
    for(int i=1;i<=n;i++)
    {
        if(viz[i]!=1)
        {
            viz[i]=1;
            if(mp[a[i]])nr[i]=2;
            for(int j=1;j<=n;j++)
            if(a[i]==a[j] && i!=j)
            {
                viz[j]=1;
                nr[j]=2;//aleg bul
                nr[i]=2;
            }
        }
        if(nr[i]==1)
        {
            if(mp[a[i]])
            {
                cout<<"NO";
                return 0;
            }
            else
                mp[a[i]]=1;
        }
        else if(nr[i]==2)
        {
            if(mp[b[i]])
            {
                cout<<"NO";
                return 0;
            }
            else
                mp[b[i]]=1;
        }
    }
    for(int i=1;i<=n;i++)if(nr[i]==0)
    {
        if(mp[a[i]] && mp[b[i]])
        {
            cout<<"NO";
            return 0;
        }
        else if(mp[b[i]])
        {
            nr[i]=1;
            mp[a[i]]=1;
        }
        else
        {
            nr[i]=2;
            mp[b[i]]=1;
        }
    }
    cout<<"YES\n";
    for(int i=1;i<=n;i++)if(nr[i]==1)cout<<a[i]<<'\n';
    else cout<<b[i]<<'\n';
    return 0;
}


#include <iostream>
#include <map>
#define Nmax 1005
using namespace std;
int n,viz[Nmax],nr[Nmax];
map<string,int>mp;
string s1,s2,a[Nmax],b[Nmax];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>s1>>s2;
        a[i]="";b[i]="";
        a[i].push_back(s1[0]);a[i].push_back(s1[1]);a[i].push_back(s1[2]);
        b[i].push_back(s1[0]);b[i].push_back(s1[1]);b[i].push_back(s2[0]);
    }
    for(int i=1;i<=n;i++)
    {
        if(viz[i]!=1)
        {
            viz[i]=1;
            if(mp[a[i]])nr[i]=2;
            for(int j=1;j<=n;j++)
            if(a[i]==a[j] && i!=j)
            {
                viz[j]=1;
                nr[j]=2;//aleg bul
                nr[i]=2;
            }
        }
        if(nr[i]==1)
        {
            if(mp[a[i]])
            {
                cout<<"NO";
                return 0;
            }
            else
                mp[a[i]]=1;
        }
        else if(nr[i]==2)
        {
            if(mp[b[i]])
            {
                cout<<"NO";
                return 0;
            }
            else
                mp[b[i]]=1;
        }
    }
    for(int i=1;i<=n;i++)if(nr[i]==0)
    {
        if(mp[a[i]] && mp[b[i]])
        {
            cout<<"NO";
            return 0;
        }
        else if(mp[a[i]])nr[i]=2;
        else nr[i]=1;
    }
    cout<<"YES\n";
    for(int i=1;i<=n;i++)if(nr[i]==1)cout<<a[i]<<'\n';
    else cout<<b[i]<<'\n';
    return 0;
}


#include <iostream>
#include <map>
#define Nmax 1005
using namespace std;
int n,viz[Nmax],nr[Nmax];
map<string,int>mp;
string s1,s2,a[Nmax],b[Nmax];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>s1>>s2;
        a[i]="";b[i]="";
        a[i].push_back(s1[0]);a[i].push_back(s1[1]);a[i].push_back(s1[2]);
        b[i].push_back(s1[0]);b[i].push_back(s1[1]);b[i].push_back(s2[0]);
    }

    for(int i=1;i<=n;i++)
    {
        if(viz[i]!=1)
        {
            viz[i]=1;
            if(mp[a[i]])nr[i]=2;
            for(int j=1;j<=n;j++)
            if(a[i]==a[j] && i!=j)
            {
                viz[j]=1;
                nr[j]=2;//aleg bul
                nr[i]=2;
            }
        }
        if(nr[i]==1)
        {
            if(mp[a[i]])
            {
                cout<<"NO";
                return 0;
            }
            else
                mp[a[i]]=1;
        }
        else if(nr[i]==2)
        {
            if(mp[b[i]])
            {
                cout<<"NO";
                return 0;
            }
            else
                mp[b[i]]=1;
        }
    }
    for(int i=1;i<=n;i++)if(nr[i]==0)
    {
        if(mp[a[i]] && mp[b[i]])
        {
            cout<<"NO";
            return 0;
        }
        else if(mp[b[i]])
        {
            nr[i]=1;
            mp[a[i]]=1;
        }
        else
        {
            nr[i]=2;
            mp[b[i]]=1;
        }
    }
    cout<<"YES\n";
    for(int i=1;i<=n;i++)if(nr[i]==1)cout<<a[i]<<'\n';
    else cout<<b[i]<<'\n';
    return 0;
}


#include <iostream>
#include <map>
#define Nmax 1005
using namespace std;
int n,viz[Nmax],nr[Nmax];
map<string,int>mp;
string s1,s2,a[Nmax],b[Nmax];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>s1>>s2;
        a[i]="";b[i]="";
        a[i].push_back(s1[0]);a[i].push_back(s1[1]);a[i].push_back(s1[2]);
        b[i].push_back(s1[0]);b[i].push_back(s1[1]);b[i].push_back(s2[0]);
    }
    for(int i=1;i<=n;i++)
    {
        if(viz[i]!=1)
        {
            viz[i]=1;
            if(mp[a[i]])nr[i]=2;
            else nr[i]=1;
            for(int j=1;j<=n;j++)
            if(a[i]==a[j] && i!=j)
            {
                viz[j]=1;
                nr[j]=2;//aleg bul
                nr[i]=2;
            }
        }
        if(nr[i]==1)
        {
            if(mp[a[i]])
            {
                cout<<"NO";
                return 0;
            }
            else
                mp[a[i]]=1;
        }
        else
        {
            if(mp[b[i]])
            {
                cout<<"NO";
                return 0;
            }
            else
                mp[b[i]]=1;
        }
    }
    cout<<"YES\n";
    for(int i=1;i<=n;i++)if(nr[i]==1)cout<<a[i]<<'\n';
    else cout<<b[i]<<'\n';
    return 0;
}


#include <iostream>
#include <map>
#define Nmax 1005
using namespace std;
int n,viz[Nmax],nr[Nmax];
map<string,int>mp;
string s1,s2,a[Nmax],b[Nmax];
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>s1>>s2;
        a[i]="";b[i]="";
        a[i].push_back(s1[0]);a[i].push_back(s1[1]);a[i].push_back(s1[2]);
        b[i].push_back(s1[0]);b[i].push_back(s1[1]);b[i].push_back(s2[0]);
    }
    for(int i=1;i<=n;i++)
    {
        if(viz[i]!=1)
        {
            viz[i]=1;
            if(mp[a[i]])nr[i]=2;
            for(int j=1;j<=n;j++)
            if(a[i]==a[j] && i!=j)
            {
                viz[j]=1;
                nr[j]=2;//aleg bul
                nr[i]=2;
            }
        }
        if(nr[i]==1)
        {
            if(mp[a[i]])
            {
                cout<<"NO";
                return 0;
            }
            else
                mp[a[i]]=1;
        }
        else if(nr[i]==2)
        {
            if(mp[b[i]])
            {
                cout<<"NO";
                return 0;
            }
            else
                mp[b[i]]=1;
        }
    }
    for(int i=1;i<=n;i++)if(nr[i]==0)
    {
        if(mp[a[i]] && mp[b[i]])
        {
            cout<<"NO";
            return 0;
        }
        else if(mp[a[i]])
        {
            nr[i]=2;
            mp[b[i]]=1;
        }
        else
        {
            nr[i]=1;
            mp[a[i]]=1;
        }
    }
    cout<<"YES\n";
    for(int i=1;i<=n;i++)if(nr[i]==1)cout<<a[i]<<'\n';
    else cout<<b[i]<<'\n';
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
string s1,s2,s;
int n,i,f[30][30][30],a,b,c,j,k;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>s1>>s2;
        a=s1[0]-'A';
        b=s1[1]-'A';
        c=s2[0]-'A';
        f[a][b][c]++;
        if(f[a][b][c]>1)
        {
            if(f[a][b][s1[2]-'A']>0){
            cout<<"NO\n";
            return 0;}
            else
            {
                f[a][b][s1[2]-'A']++;
                s.push_back(char(a+'A'));
                s.push_back(char(b+'A'));
                s.push_back(s1[2]);
                s.push_back('\n');
            }
        }
        else
        {
            s.push_back(char(a+'A'));
            s.push_back(char(b+'A'));
            s.push_back(char(c+'A'));
            s.push_back('\n');
        }
    }
    cout<<"YES\n";
    cout<<s;
    return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;

int n,i,in1,nr,ind1,ind2,ok;
string s1,s2,c1,c2,s3,s4;
pair <pair <string,string>,int > p[1005];
map <string, short int> mp;
map <int, string> ans;
queue < pair <pair <string,string>,int > > Q;
pair <pair <string,string>,int > per;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>s1>>s2;
        c1 = s1[0] + s1[1] + s1[2];
        c1= s1.substr(0,3);
        c2=s1.substr(0,2)+s2.substr(0,1);
        p[i]={{c1,c2},i};
    }
    sort(p+1,p+1+n);
    nr=n;
    for(i=1;i<=nr;i++)
    {
        s1 = p[i-1].F.F;
        s2= p[i].F.F;
        s3= p[i].F.S;
        s4= p[i+1].F.F;

        if(s1==s2 or s2==s4)
        {
            if(mp.find(s3)==mp.end())ans[p[i].S] = s3 , mp[s3]=1;
            else
            {
                cout<<"NO\n";
                return 0;
            }
        }
        else Q.push(p[i]);
    }

    ok=1;
    while(ok)
    {
        ok=0;
        nr=Q.size();
        while(nr)
        {
            nr--;
            per = Q.front();
            Q.pop();
            s1 = per.F.F;
            s2 = per.F.S;
            ind1 = per.S;

            if(mp.find(s1)!=mp.end())
            {
                if(mp.find(s2) == mp.end())
                {
                    ans[ind1] = s2;
                    mp[s2] = 1;
                    ok++;
                }
                else {
                cout<<"NO\n";
                return 0;
                }
            }
            else
            {
                Q.push(per);

            }
        }

    }
    while(!Q.empty())
    {
        per = Q.front();
        Q.pop();
        s1 = per.F.F;
        s2 = per.F.S;
        ind1 = per.S;
        ans[ind1] = s1;
       // cout<<ind1<<"\n";
    }
    cout<<"YES\n";
    for(i=1;i<=n;i++)
        cout<<ans[i]<<"\n";
    return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;

int n,i,in1,nr,ind1,ind2,ok;
string s1,s2,c1,c2,s3,s4;
pair <pair <string,string>,int > p[1005];
map <string, short int> mp;
map <int, string> ans;
queue < pair <pair <string,string>,int > > Q;
pair <pair <string,string>,int > per;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>s1>>s2;
        c1 = s1[0] + s1[1] + s1[2];
        c1= s1.substr(0,3);
        c2=s1.substr(0,2)+s2.substr(0,1);
        p[i]={{c1,c2},i};
    }
    sort(p+1,p+1+n);
    nr=n;
    for(i=1;i<=nr;i++)
    {
        s1 = p[i-1].F.F;
        s2= p[i].F.F;
        s3= p[i].F.S;
        s4= p[i+1].F.F;

        if(s1==s2 or s2==s4)
        {
            if(mp[s3]==0)ans[p[i].S] = s3 , mp[s3]=1;
        }
        else Q.push(p[i]);
    }

    ok=1;
    while(ok)
    {
        ok=0;
        nr=Q.size();
        while(nr)
        {
            nr--;
            per = Q.front();
            Q.pop();
            s1 = per.F.F;
            s2 = per.F.S;
            ind1 = per.S;

            if(mp[s1]==1 and mp[s2]==0)
            {
                ans[ind1] = s2;
                mp[s2] = 1;
                ok++;
            }
            else if(mp[s2]==0)Q.push(per);
            else
            {
                cout<<"NO\n";
                return 0;
            }
        }

    }
    while(!Q.empty())
    {
        per = Q.front();
        Q.pop();
        s1 = per.F.F;
        s2 = per.F.S;
        ind1 = per.S;
        ans[ind1] = s1;
       // cout<<ind1<<"\n";
    }
    cout<<"YES\n";
    for(i=1;i<=n;i++)
        cout<<ans[i]<<"\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;
string s1,s2,s;
map <string,int > mp;
int n,i,f[30][30][30],a,b,c,j,k;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>s1>>s2;
        string str;
        str.clear();
        str=s1[0]+s1[1]+s1[2]+s2[0];
        mp[str]++;
        if(mp[str]>1)
        {
            cout<<"NO\n";
            return 0;
        }
        a=s1[0]-'A';
        b=s1[1]-'A';
        c=s2[0]-'A';
        f[a][b][c]++;
        if(f[a][b][c]>1)
        {
            if(f[a][b][s1[2]-'A']>0){
            cout<<"NO\n";
            return 0;}
            else
            {
                f[a][b][s1[2]-'A']++;
                s.push_back(char(a+'A'));
                s.push_back(char(b+'A'));
                s.push_back(s1[2]);
                s.push_back('\n');
            }
        }
        else
        {
            s.push_back(char(a+'A'));
            s.push_back(char(b+'A'));
            s.push_back(char(c+'A'));
            s.push_back('\n');
        }
    }
    cout<<"YES\n";
    cout<<s;
    return 0;
}


#include <iostream>
#include <string>
using namespace std;
string s1,s2,s;
int n,i,f[30][30][30],a,b,c,j,k;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>s1>>s2;
        a=s1[0]-'A';
        b=s1[1]-'A';
        c=s2[0]-'A';
        f[a][b][c]++;
        if(f[a][b][c]>1)
        {
            cout<<"NO\n";
            return 0;
        }
        else
        {
            s.push_back(char(a+'A'));
            s.push_back(char(b+'A'));
            s.push_back(char(c+'A'));
            s.push_back('\n');
        }
    }
    cout<<"YES\n";
    cout<<s;
    return 0;
}


#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;

int n,i,in1,nr,ind1,ind2,ok;
string s1,s2,c1,c2,s3,s4;
pair <pair <string,string>,int > p[1005];
map <string, short int> mp;
map <int, string> ans;
queue < pair <pair <string,string>,int > > Q;
pair <pair <string,string>,int > per;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>s1>>s2;
        c1 = s1[0] + s1[1] + s1[2];
        c1= s1.substr(0,3);
        c2=s1.substr(0,2)+s2.substr(0,1);
        p[i]={{c1,c2},i};
    }
    sort(p+1,p+1+n);
    nr=n;
    for(i=1;i<=nr;i++)
    {
        s1 = p[i-1].F.F;
        s2= p[i].F.F;
        s3= p[i].F.S;
        s4= p[i+1].F.F;

        if(s1==s2 or s2==s4)
        {
            if(mp.find(s3)==mp.end())ans[p[i].S] = s3 , mp[s3]=1;
            else
            {
                cout<<"NO\n";
                return 0;
            }
        }
        else Q.push(p[i]);
    }

    ok=1;
    while(ok)
    {
        ok=0;
        nr=Q.size();
        while(nr)
        {
            nr--;
            per = Q.front();
            Q.pop();
            s1 = per.F.F;
            s2 = per.F.S;
            ind1 = per.S;

            if(mp[s1]==1)
            {
                if(mp.find(s2) == mp.end())
                {
                    ans[ind1] = s2;
                    mp[s2] = 1;
                    ok++;
                }
                else {
                cout<<"NO\n";
                return 0;
                }
            }
            else
            {
                Q.push(per);

            }
        }

    }
    while(!Q.empty())
    {
        per = Q.front();
        Q.pop();
        s1 = per.F.F;
        s2 = per.F.S;
        ind1 = per.S;
        ans[ind1] = s1;
       // cout<<ind1<<"\n";
    }
    cout<<"YES\n";
    for(i=1;i<=n;i++)
        cout<<ans[i]<<"\n";
    return 0;
}


//IN THE NAME OF GOD\\

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <int , int> pii;

const int maxn = 1e3+10 , maxk=2e5+10 , MOD = 1e9+7 , inf=1e9+10;

int mark[maxk] , f[maxk] , ans[maxn] , t1[maxn] , t2[maxn] , match[maxk];
bool mk[maxn] , p[maxk];
vector <int> g[maxk];

bool dfs(int u , int t){
    if(mark[u])
        return false;
    mark[u]=1;
    for(int v:g[u])
        if(!match[v] || dfs(match[v] , 1-t))
        {
            if(!t)
                ans[u]=v;
            else
                ans[v]=u;
            match[v]=u;
            match[u]=v;
            return true;
        }
    return false;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    string s1,s2;
    cin>>n;
    for(int i=1 ; i<=n ; i++){
        cin>>s1>>s2;
        t1[i] = 27*27*(s1[0]-'A') + 27*(s1[1]-'A') + (s1[2]-'A');
        t1[i]+=100000;
        t2[i] = 27*27*(s1[0]-'A') + 27*(s1[1]-'A') + (s2[0]-'A');
        t2[i]+=100000;
        if(mark[t1[i]]==1){
            mk[f[t1[i]]]=true;
            ans[f[t1[i]]]=t2[f[t1[i]]];
            if(p[t2[f[t1[i]]]]){
                cout<<"NO";
                return 0;
            }
            p[t2[f[t1[i]]]]=true;
        }
        if(mark[t1[i]]>0){
            mk[i]=true;
            ans[i]=t2[i];
            if(p[t2[i]]){
                cout<<"NO";
                return 0;
            }
            p[t2[i]]=true;
        }
        mark[t1[i]]++;
        f[t1[i]]=i;
    }
    memset(mark , 0 , sizeof(mark));
    for(int i=1 ; i<=n ; i++){
        if(mk[i])
            continue;
        if(!p[t1[i]]){
            g[i].push_back(t1[i]);
            g[t1[i]].push_back(i);
        }
        if(!p[t2[i]]){
            g[i].push_back(t2[i]);
            g[t2[i]].push_back(i);
        }
    }
    for(int i=1 ; i<=n ; i++){
        if(mk[i])
            continue;
        memset(mark , 0 , sizeof(mark));
        if(!match[i])
            dfs(i , 0);
    }
    for(int i=1 ; i<=n ; i++){
        if(mk[i])
            continue;
        if(!match[i]){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES"<<endl;
    for(int i=1 ; i<=n ; i++){
        char a,b,c;
        ans[i]-=100000;
        a=char('A'+(ans[i]%27));
        ans[i]-=(ans[i]%27);
        ans[i]/=27;
        b=char('A'+(ans[i]%27));
        ans[i]-=(ans[i]%27);
        ans[i]/=27;
        c=char('A'+(ans[i]%27));
        cout<<c<<b<<a<<endl;
    }
    return 0;
}


//IN THE NAME OF GOD\\

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <int , int> pii;

const int maxn = 1e3+10 , maxk=3e4+10 , MOD = 1e9+7 , inf=1e9+10;

int mark[maxk] , f[maxk] , ans[maxn] , t1[maxn] , t2[maxn];
bool mk[maxn] , p[maxk];
vector <int> g[maxk];

bool dfs(int u , int t){
    if(mark[u])
        return false;
    for(int v:g[u])
        if(!f[v] || dfs(f[v] , 1-t))
        {
            if(!t)
                ans[u]=v;
            else
                ans[v]=u;
            f[v]=u;
            f[u]=v;
            return true;
        }
    return false;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    string s1,s2;
    cin>>n;
    for(int i=1 ; i<=n ; i++){
        cin>>s1>>s2;
        t1[i] = 26*26*(s1[0]-'A') + 26*(s1[1]-'A') + (s1[2]-'A');
        t1[i]+=1001;
        t2[i] = 26*26*(s1[0]-'A') + 26*(s1[1]-'A') + (s2[0]-'A');
        t2[i]+=1001;
        if(mark[t1[i]]==1){
            mk[f[t1[i]]]=true;
            ans[f[t1[i]]]=t2[f[t1[i]]];
            if(p[t2[f[t1[i]]]]){
                cout<<"NO";
                return 0;
            }
            p[t2[f[t1[i]]]]=true;
        }
        if(mark[t1[i]]>0){
            mk[i]=true;
            ans[i]=t2[i];
            if(p[t2[i]]){
                cout<<"NO";
                return 0;
            }
            p[t2[i]]=true;
        }
        mark[t1[i]]++;
        f[t1[i]]=i;
    }
    memset(mark , 0 , sizeof(mark));
    memset(f , 0 , sizeof(f));
    for(int i=1 ; i<=n ; i++){
        if(mk[i])
            continue;
        if(!p[t1[i]]){
            g[i].push_back(t1[i]);
            g[t1[i]].push_back(i);
        }
        if(!p[t2[i]]){
            g[i].push_back(t2[i]);
            g[t2[i]].push_back(i);
        }
    }
    for(int i=1 ; i<=n ; i++){
        if(mk[i])
            continue;
        if(!f[i])
            dfs(i , 0);
    }
    for(int i=1 ; i<=n ; i++){
        if(mk[i])
            continue;
        if(!f[i]){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES"<<endl;
    for(int i=1 ; i<=n ; i++){
        char a,b,c;
        ans[i]-=1001;
        a=char('A'+(ans[i]%26));
        ans[i]-=(ans[i]%26);
        ans[i]/=26;
        b=char('A'+(ans[i]%26));
        ans[i]-=(ans[i]%26);
        ans[i]/=26;
        c=char('A'+(ans[i]%26));
        cout<<c<<b<<a<<endl;
    }
    return 0;
}


//IN THE NAME OF GOD\\

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <int , int> pii;

const int maxn = 1e3+10 , maxk=1e5+10 , MOD = 1e9+7 , inf=1e9+10;

vector < pair <string , string> > v;
string s1[maxn] , s2[maxn];
int mark[maxk] , f[maxk] , ans[maxn] , t1[maxn] , t2[maxn];
bool mk[maxk] , p[maxk];

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    for(int i=0 ; i<n ; i++){
        cin>>s1[i]>>s2[i];
        t1[i] = 27*27*(s1[i][0]-'A') + 27*(s1[i][1]-'A') + (s1[i][2]-'A');
        t2[i] = 27*27*(s1[i][0]-'A') + 27*(s1[i][1]-'A') + (s2[i][0]-'A');
        if(mark[t1[i]]==1){
            mk[f[t1[i]]]=true;
            ans[f[t1[i]]]=t2[f[t1[i]]];
            if(p[t2[f[t1[i]]]]){
                cout<<"NO";
                return 0;
            }
            p[t2[f[t1[i]]]]=true;
        }
        if(mark[t1[i]]>0){
            mk[i]=true;
            ans[i]=t2[i];
            if(p[t2[i]]){
                cout<<"NO";
                return 0;
            }
            p[t2[i]]=true;
        }
        mark[t1[i]]++;
        f[t1[i]]=i;
    }
    for(int i=0 ; i<n ; i++){
        if(mk[i])
            continue;
        if(p[t1[i]]){
            if(p[t2[i]]){
                cout<<"NO";
                return 0;
            }
            ans[i]=t2[i];
        }
        else
            ans[i]=t1[i];
    }
    cout<<"YES"<<endl;
    for(int i=0 ; i<n ; i++){
        char a,b,c;
        a=char('A'+(ans[i]%27));
        ans[i]-=(ans[i]%27);
        ans[i]/=27;
        b=char('A'+(ans[i]%27));
        ans[i]-=(ans[i]%27);
        ans[i]/=27;
        c=char('A'+(ans[i]%27));
        cout<<c<<b<<a<<endl;
    }
    return 0;
}


//IN THE NAME OF GOD\\

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <int , int> pii;

const int maxn = 1e3+10 , maxk=2e5+10 , MOD = 1e9+7 , inf=1e9+10;

string s1[maxk] , s2[maxk];
int mark[maxk] , f[maxk] , ans[maxk] , t1[maxk] , t2[maxk] , match[maxn];
bool mk[maxk] , p[maxk];
vector <int> g[maxk];

bool dfs(int u , int t){
    if(mark[u])
        return false;
    for(int v:g[u])
        if(!match[v] || dfs(match[v] , 1-t))
        {
            if(!t)
                ans[u]=v;
            else
                ans[v]=u;
            match[v]=u;
            match[u]=v;
            return true;
        }
    return false;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    for(int i=0 ; i<n ; i++){
        cin>>s1[i]>>s2[i];
        t1[i] = 27*27*(s1[i][0]-'A') + 27*(s1[i][1]-'A') + (s1[i][2]-'A');
        t1[i]+=100000;
        t2[i] = 27*27*(s1[i][0]-'A') + 27*(s1[i][1]-'A') + (s2[i][0]-'A');
        t2[i]+=100000;
        if(mark[t1[i]]==1){
            mk[f[t1[i]]]=true;
            ans[f[t1[i]]]=t2[f[t1[i]]];
            if(p[t2[f[t1[i]]]]){
                cout<<"NO";
                return 0;
            }
            p[t2[f[t1[i]]]]=true;
        }
        if(mark[t1[i]]>0){
            mk[i]=true;
            ans[i]=t2[i];
            if(p[t2[i]]){
                cout<<"NO";
                return 0;
            }
            p[t2[i]]=true;
        }
        mark[t1[i]]++;
        f[t1[i]]=i;
    }
    memset(mark , 0 , sizeof(mark));
    for(int i=0 ; i<n ; i++){
        if(mk[i])
            continue;
        if(!p[t1[i]]){
            g[i].push_back(t1[i]);
            g[t1[i]].push_back(i);
        }
        if(!p[t2[i]]){
            g[i].push_back(t2[i]);
            g[t2[i]].push_back(i);
        }
    }
    for(int i=0 ; i<n ; i++){
        if(mk[i])
            continue;
        if(!match[i])
            dfs(i , 0);
    }
    for(int i=0 ; i<n ; i++){
        if(mk[i])
            continue;
        if(!match[i]){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES"<<endl;
    for(int i=0 ; i<n ; i++){
        char a,b,c;
        ans[i]-=100000;
        a=char('A'+(ans[i]%27));
        ans[i]-=(ans[i]%27);
        ans[i]/=27;
        b=char('A'+(ans[i]%27));
        ans[i]-=(ans[i]%27);
        ans[i]/=27;
        c=char('A'+(ans[i]%27));
        cout<<c<<b<<a<<endl;
    }
    return 0;
}


//IN THE NAME OF GOD\\

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <int , int> pii;

const int maxn = 1e3+10 , MOD = 1e9+7 , inf=1e9+10;

string s[maxn] , t[maxn] , ans[maxn];
bool mark[maxn] , sw;
map <string , bool> mp;
map <string , int> m;
vector <int> v;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    for(int i=1 ; i<=n ; i++){
        cin>>s[i]>>t[i];
        s[i] = s[i].substr(0 , 3);
        t[i] = s[i].substr(0 , 2) + t[i][0];
    }
    for(int i=1 ; i<=n ; i++){
        if(!mark[i]){
            for(int j=i+1 ; j<=n ; j++){
                if(s[i]==s[j]){
                    if(!sw){
                        mark[i]=true;
                        sw=true;
                        ans[i]=t[i];
                        if(mp[t[i]]){
                            cout<<"NO";
                            return 0;
                        }
                        mp[t[i]]=true;
                        v.push_back(i);
                    }
                    v.push_back(j);
                    mark[j]=true;
                    ans[j]=t[j];
                    if(mp[t[j]]){
                        cout<<"NO";
                        return 0;
                    }
                    mp[t[j]]=true;
                }
            }
        }
        if(!mark[i])
            m[s[i]]=i;
    }
    for(int i:v){
        if(m[ans[i]]){
            int u = m[ans[i]];
            ans[u]=t[u];
            if(mp[t[u]]){
                cout<<"NO";
                return 0;
            }
            mp[t[u]]=true;
            v.push_back(u);
        }
    }
    cout<<"YES"<<endl;
    for(int i=1 ; i<=n ; i++)
        if(ans[i] != "")
            cout<<ans[i]<<endl;
        else
            cout<<s[i]<<endl;
    return 0;
}


//IN THE NAME OF GOD\\

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <int , int> pii;

const int maxn = 1e3+10 , MOD = 1e9+7 , inf=1e9+10;

string s[maxn] , t[maxn] , ans[maxn];
bool mark[maxn] , sw;
map <string , bool> mp;
map <string , int> m;
vector <int> v;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    for(int i=1 ; i<=n ; i++){
        cin>>s[i]>>t[i];
        s[i] = s[i].substr(0 , 3);
        t[i] = s[i].substr(0 , 2) + t[i][0];
    }
    for(int i=1 ; i<=n ; i++){
        sw=false;
        if(!mark[i]){
            for(int j=i+1 ; j<=n ; j++){
                if(s[i] == s[j]){
                    if(!sw){
                        mark[i]=true;
                        sw=true;
                        ans[i]=t[i];
                        if(mp[t[i]]){
                            cout<<"NO";
                            return 0;
                        }
                        mp[t[i]]=true;
                        v.push_back(i);
                    }
                    v.push_back(j);
                    mark[j]=true;
                    ans[j]=t[j];
                    if(mp[t[j]]){
                        cout<<"NO";
                        return 0;
                    }
                    mp[t[j]]=true;
                }
            }
        }
        if(!mark[i])
            m[s[i]]=i;
    }
    for(int p=0 ; p<v.size() ; p++){
        int i = v[p];
        if(m[ans[i]]){
            int u = m[ans[i]];
            ans[u]=t[u];
            if(mp[t[u]]){
                cout<<"NO";
                return 0;
            }
            mp[t[u]]=true;
            v.push_back(u);
        }
    }
    cout<<"YES"<<endl;
    for(int i=1 ; i<=n ; i++)
        if(ans[i] != "")
            cout<<ans[i]<<endl;
        else
            cout<<s[i]<<endl;
    return 0;
}


//IN THE NAME OF GOD\\

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <int , int> pii;

const int maxn = 1e3+10 , maxk=3e4+10 , MOD = 1e9+7 , inf=1e9+10;

int mark[maxk] , f[maxk] , ans[maxn] , t1[maxn] , t2[maxn] , match[maxk];
bool mk[maxn] , p[maxk];
vector <int> g[maxk];

bool dfs(int u , int t){
    if(mark[u])
        return false;
    for(int v:g[u])
        if(!match[v] || dfs(match[v] , 1-t))
        {
            if(!t)
                ans[u]=v;
            else
                ans[v]=u;
            match[v]=u;
            match[u]=v;
            return true;
        }
    return false;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    string s1,s2;
    cin>>n;
    for(int i=0 ; i<n ; i++){
        cin>>s1>>s2;
        t1[i] = 26*26*(s1[0]-'A') + 26*(s1[1]-'A') + (s1[2]-'A');
        t1[i]+=1000;
        t2[i] = 26*26*(s1[0]-'A') + 26*(s1[1]-'A') + (s2[0]-'A');
        t2[i]+=1000;
        if(mark[t1[i]]==1){
            mk[f[t1[i]]]=true;
            ans[f[t1[i]]]=t2[f[t1[i]]];
            if(p[t2[f[t1[i]]]]){
                cout<<"NO";
                return 0;
            }
            p[t2[f[t1[i]]]]=true;
        }
        if(mark[t1[i]]>0){
            mk[i]=true;
            ans[i]=t2[i];
            if(p[t2[i]]){
                cout<<"NO";
                return 0;
            }
            p[t2[i]]=true;
        }
        mark[t1[i]]++;
        f[t1[i]]=i;
    }
    memset(mark , 0 , sizeof(mark));
    for(int i=0 ; i<n ; i++){
        if(mk[i])
            continue;
        if(!p[t1[i]]){
            g[i].push_back(t1[i]);
            g[t1[i]].push_back(i);
        }
        if(!p[t2[i]]){
            g[i].push_back(t2[i]);
            g[t2[i]].push_back(i);
        }
    }
    for(int i=0 ; i<n ; i++){
        if(mk[i])
            continue;
        if(!match[i])
            dfs(i , 0);
    }
    for(int i=0 ; i<n ; i++){
        if(mk[i])
            continue;
        if(!match[i]){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES"<<endl;
    for(int i=0 ; i<n ; i++){
        char a,b,c;
        ans[i]-=1000;
        a=char('A'+(ans[i]%26));
        ans[i]-=(ans[i]%26);
        ans[i]/=26;
        b=char('A'+(ans[i]%26));
        ans[i]-=(ans[i]%26);
        ans[i]/=26;
        c=char('A'+(ans[i]%26));
        cout<<c<<b<<a<<endl;
    }
    return 0;
}


//IN THE NAME OF GOD\\

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <int , int> pii;

const int maxn = 1e3+10 , maxk=1e5+10 , MOD = 1e9+7 , inf=1e9+10;

string s1[maxk] , s2[maxk];
int mark[maxk] , f[maxk] , ans[maxk] , t1[maxk] , t2[maxk] , match[maxn];
bool mk[maxk] , p[maxk];
vector <int> g[maxk];

bool dfs(int u , int t){
    if(mark[u])
        return false;
    for(int v:g[u])
        if(!match[v] || dfs(match[v] , 1-t))
        {
            if(!t)
                ans[u]=v;
            else
                ans[v]=u;
            match[v]=u;
            match[u]=v;
            return true;
        }
    return false;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    for(int i=0 ; i<n ; i++){
        cin>>s1[i]>>s2[i];
        t1[i] = 27*27*(s1[i][0]-'A') + 27*(s1[i][1]-'A') + (s1[i][2]-'A');
        t2[i] = 27*27*(s1[i][0]-'A') + 27*(s1[i][1]-'A') + (s2[i][0]-'A');
        if(mark[t1[i]]==1){
            mk[f[t1[i]]]=true;
            ans[f[t1[i]]]=t2[f[t1[i]]];
            if(p[t2[f[t1[i]]]]){
                cout<<"NO";
                return 0;
            }
            p[t2[f[t1[i]]]]=true;
        }
        if(mark[t1[i]]>0){
            mk[i]=true;
            ans[i]=t2[i];
            if(p[t2[i]]){
                cout<<"NO";
                return 0;
            }
            p[t2[i]]=true;
        }
        mark[t1[i]]++;
        f[t1[i]]=i;
    }
    memset(mark , 0 , sizeof(mark));
    for(int i=0 ; i<n ; i++){
        if(mk[i])
            continue;
        if(!p[t1[i]]){
            g[i].push_back(t1[i]);
            g[t1[i]].push_back(i);
        }
        if(!p[t2[i]]){
            g[i].push_back(t2[i]);
            g[t2[i]].push_back(i);
        }
    }
    for(int i=0 ; i<n ; i++){
        if(mk[i])
            continue;
        if(!match[i])
            dfs(i , 0);
    }
    for(int i=0 ; i<n ; i++){
        if(mk[i])
            continue;
        if(!match[i]){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES"<<endl;
    for(int i=0 ; i<n ; i++){
        char a,b,c;
        a=char('A'+(ans[i]%27));
        ans[i]-=(ans[i]%27);
        ans[i]/=27;
        b=char('A'+(ans[i]%27));
        ans[i]-=(ans[i]%27);
        ans[i]/=27;
        c=char('A'+(ans[i]%27));
        cout<<c<<b<<a<<endl;
    }
    return 0;
}


//IN THE NAME OF GOD\\

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <int , int> pii;

const int maxn = 1e3+10 , maxk=1e5+10 , MOD = 1e9+7 , inf=1e9+10;

string s1[maxn] , s2[maxn];
int mark[maxk] , f[maxk] , ans[maxn] , t1[maxn] , t2[maxn] , match[maxk];
bool mk[maxn] , p[maxk];
vector <int> g[maxk];

bool dfs(int u , int t){
    if(mark[u])
        return false;
    for(int v:g[u])
        if(!match[v] || dfs(match[v] , 1-t))
        {
            if(!t)
                ans[u]=v;
            else
                ans[v]=u;
            match[v]=u;
            match[u]=v;
            return true;
        }
    return false;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    for(int i=0 ; i<n ; i++){
        cin>>s1[i]>>s2[i];
        t1[i] = 27*27*(s1[i][0]-'A') + 27*(s1[i][1]-'A') + (s1[i][2]-'A');
        t1[i]+=10000;
        t2[i] = 27*27*(s1[i][0]-'A') + 27*(s1[i][1]-'A') + (s2[i][0]-'A');
        t2[i]+=10000;
        if(mark[t1[i]]==1){
            mk[f[t1[i]]]=true;
            ans[f[t1[i]]]=t2[f[t1[i]]];
            if(p[t2[f[t1[i]]]]){
                cout<<"NO";
                return 0;
            }
            p[t2[f[t1[i]]]]=true;
        }
        if(mark[t1[i]]>0){
            mk[i]=true;
            ans[i]=t2[i];
            if(p[t2[i]]){
                cout<<"NO";
                return 0;
            }
            p[t2[i]]=true;
        }
        mark[t1[i]]++;
        f[t1[i]]=i;
    }
    memset(mark , 0 , sizeof(mark));
    for(int i=0 ; i<n ; i++){
        if(mk[i])
            continue;
        if(!p[t1[i]]){
            g[i].push_back(t1[i]);
            g[t1[i]].push_back(i);
        }
        if(!p[t2[i]]){
            g[i].push_back(t2[i]);
            g[t2[i]].push_back(i);
        }
    }
    for(int i=0 ; i<n ; i++){
        if(mk[i])
            continue;
        if(!match[i])
            dfs(i , 0);
    }
    for(int i=0 ; i<n ; i++){
        if(mk[i])
            continue;
        if(!match[i]){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES"<<endl;
    for(int i=0 ; i<n ; i++){
        char a,b,c;
        ans[i]-=10000;
        a=char('A'+(ans[i]%27));
        ans[i]-=(ans[i]%27);
        ans[i]/=27;
        b=char('A'+(ans[i]%27));
        ans[i]-=(ans[i]%27);
        ans[i]/=27;
        c=char('A'+(ans[i]%27));
        cout<<c<<b<<a<<endl;
    }
    return 0;
}


//IN THE NAME OF GOD\\

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <int , int> pii;

const int maxn = 1e3+10 , maxk=1e5+10 , MOD = 1e9+7 , inf=1e9+10;

int mark[maxk] , f[maxk] , ans[maxn] , t1[maxn] , t2[maxn] , match[maxk];
bool mk[maxn] , p[maxk];
vector <int> g[maxk];

bool dfs(int u , int t){
    if(mark[u])
        return false;
    mark[u]=1;
    for(int v:g[u])
        if(!match[v] || dfs(match[v] , 1-t))
        {
            if(!t)
                ans[u]=v;
            else
                ans[v]=u;
            match[v]=u;
            match[u]=v;
            return true;
        }
    return false;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    string s1,s2;
    cin>>n;
    for(int i=1 ; i<=n ; i++){
        cin>>s1>>s2;
        t1[i] = 27*27*(s1[0]-'A') + 27*(s1[1]-'A') + (s1[2]-'A');
        t1[i]+=10000;
        t2[i] = 27*27*(s1[0]-'A') + 27*(s1[1]-'A') + (s2[0]-'A');
        t2[i]+=10000;
        if(mark[t1[i]]==1){
            mk[f[t1[i]]]=true;
            ans[f[t1[i]]]=t2[f[t1[i]]];
            if(p[t2[f[t1[i]]]]){
                cout<<"NO";
                return 0;
            }
            p[t2[f[t1[i]]]]=true;
        }
        if(mark[t1[i]]>0){
            mk[i]=true;
            ans[i]=t2[i];
            if(p[t2[i]]){
                cout<<"NO";
                return 0;
            }
            p[t2[i]]=true;
        }
        mark[t1[i]]++;
        f[t1[i]]=i;
    }
    memset(mark , 0 , sizeof(mark));
    for(int i=1 ; i<=n ; i++){
        if(mk[i])
            continue;
        if(!p[t1[i]]){
            g[i].push_back(t1[i]);
            g[t1[i]].push_back(i);
        }
        if(!p[t2[i]]){
            g[i].push_back(t2[i]);
            g[t2[i]].push_back(i);
        }
    }
    for(int i=1 ; i<=n ; i++){
        if(mk[i])
            continue;
        memset(mark , 0 , sizeof(mark));
        if(!match[i])
            dfs(i , 0);
    }
    for(int i=1 ; i<=n ; i++){
        if(mk[i])
            continue;
        if(!match[i]){
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES"<<endl;
    for(int i=1 ; i<=n ; i++){
        char a,b,c;
        ans[i]-=10000;
        a=char('A'+(ans[i]%27));
        ans[i]-=(ans[i]%27);
        ans[i]/=27;
        b=char('A'+(ans[i]%27));
        ans[i]-=(ans[i]%27);
        ans[i]/=27;
        c=char('A'+(ans[i]%27));
        cout<<c<<b<<a<<endl;
    }
    return 0;
}