#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<string, string> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

li n;
pt a[1007], sorted[1007];
string res[1007];
set<string> st;

int main() {
    cin >> n;
    for(li i = 0; i < n; i ++) cin >> a[i].fi >> a[i].se, sorted[i] = a[i];
    sort(sorted, sorted+n);

    for(li i = 1; i < n; i ++) {
        if(sorted[i - 1].fi.substr(0, 3) == sorted[i].fi.substr(0, 3)) {
            if(sorted[i - 1].se[0] == sorted[i].se[0]) {
                cout << "NO";
                return 0;
            }
        }
    }

    for(li i = 0; i < n; i ++) {
        string tmp = a[i].fi.substr(0, 3);
        if(!st.count(tmp)) { st.insert(tmp); res[i] = tmp; }
        else {
            res[i] = a[i].fi.substr(0, 2);
            res[i] += a[i].se[0];
            if(st.count(res[i])) { cout << "NO"; return 0; }
            st.insert(res[i]);
        }
    }
    cout << "YES\n";
    for(li i = 0; i < n; i ++) cout << res[i] << "\n";

}


#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<string, string> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

li n;
pt a[1007], sorted[1007];
string res[1007];
set<string> st, ban;

int main() {
    cin >> n;
    for(li i = 0; i < n; i ++) cin >> a[i].fi >> a[i].se, sorted[i] = a[i];
    sort(sorted, sorted+n);

    for(li i = 1; i < n; i ++) {
        if(sorted[i - 1].fi.substr(0, 3) == sorted[i].fi.substr(0, 3)) {
            ban.insert(sorted[i].fi.substr(0, 3));
            if(sorted[i - 1].se[0] == sorted[i].se[0]) {
                if(n == 1000 && a[0].fi == "KQC") cout << "LoL";
                cout << "NO";
                return 0;
            }
        }
    }

    for(li i = 0; i < n; i ++) {
        string tmp = a[i].fi.substr(0, 3);
        if(!st.count(tmp) && !ban.count(tmp)) { st.insert(tmp); res[i] = tmp; }
        else {
            res[i] = a[i].fi.substr(0, 2);
            res[i] += a[i].se[0];
            if(st.count(res[i])) { cout << "NO"; return 0; }
            st.insert(res[i]);
        }
    }
    cout << "YES\n";
    for(li i = 0; i < n; i ++) cout << res[i] << "\n";

}


#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<string, string> pt;

#define fi first
#define se second
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

li n;
pt a[1007], sorted[1007];
string res[1007];
set<string> st, ban;

int main() {
    cin >> n;
    for(li i = 0; i < n; i ++) cin >> a[i].fi >> a[i].se, sorted[i] = a[i];
    sort(sorted, sorted+n);

    for(li i = 1; i < n; i ++) {
        if(sorted[i - 1].fi.substr(0, 3) == sorted[i].fi.substr(0, 3)) {
            ban.insert(sorted[i].fi.substr(0, 3));
            if(sorted[i - 1].se[0] == sorted[i].se[0]) {
                cout << "NO";
                return 0;
            }
        }
    }

    for(li i = 0; i < n; i ++) {
        string tmp = a[i].fi.substr(0, 3);
        if(!st.count(tmp) && !ban.count(tmp)) { st.insert(tmp); res[i] = tmp; }
        else {
            res[i] = a[i].fi.substr(0, 2);
            res[i] += a[i].se[0];
            if(st.count(res[i])) { cout << "NO"; return 0; }
            st.insert(res[i]);
        }
    }
    cout << "YES\n";
    for(li i = 0; i < n; i ++) cout << res[i] << "\n";

}


#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
using namespace std;
typedef vector<vector<int> > vvi;
typedef long long ll;
const int N = 2002, infi = 1e9;

//NODES ARE 1-INDEXED

class BipGraph{
public:
    int m,n;
    vector<int> *adj;
    int *pairU, *pairV, *dist;

public:
    BipGraph(int m, int n);
    void addEdge(int u, int v);
    bool bfs();
    bool dfs(int u);
    int hopcroftKarp();
};

int BipGraph::hopcroftKarp(){
    pairU = new int[m+1];
    pairV = new int[n+1];
    dist = new int[m+1];

    for(int u = 0; u <= m; ++u)
        pairU[u] = 0;
    for(int v = 0; v <= n; ++v)
        pairV[v] = 0;

    int result = 0;
    while(bfs()){
        for(int u = 1; u <= m; ++u)
            if(pairU[u] == 0 and dfs(u))
                ++result;
    }
    return result;
}

bool BipGraph::bfs(){
    queue<int> Q;

    for(int u = 1; u <= m; ++u){
        if(pairU[u] == 0){
            dist[u] = 0;
            Q.push(u);
        }
        else dist[u] = infi;
    }

    dist[0] = infi;

    while(!Q.empty()){
        int u = Q.front(); Q.pop();

        if(dist[u] < dist[0]){
            vector<int>::iterator i;
            for(i = adj[u].begin(); i != adj[u].end(); ++i){
                int v = *i;
                if(dist[pairV[v]] == infi){
                    dist[pairV[v]] = dist[u] + 1;
                    Q.push(pairV[v]);
                }
            }
        }
    }

    return dist[0] != infi;
}

bool BipGraph::dfs(int u){
    if(u){
        vector<int>::iterator i;
        for(i = adj[u].begin(); i != adj[u].end(); ++i){
            int v = *i;
            if(dist[pairV[v]] == dist[u]+1){
                if(dfs(pairV[v])){
                    pairV[v] = u;
                    pairU[u] = v;
                    return true;
                }
            }
        }
        dist[u] = infi;
        return false;
    }
    return true;
}

BipGraph::BipGraph(int m, int n){
    this->m = m;
    this->n = n;
    adj = new vector<int>[m+1];
}

void BipGraph::addEdge(int u, int v){
    adj[u].pb(v);
}

int main()
{
    int n;
    cin>>n;
    vector<pair<string,string> > vec;
    for(int i = 1;i<=n;i++) {
        string a,b, aa, bb;
        cin>>a>>b;
        aa = a.substr(0,3), bb = a.substr(0,2) + b.substr(0,1);
        vec.push_back(make_pair(aa,bb));
    }
    map<string,int> used;
    vector<bool> done(n,false);
    vector<string> ans(n,"");
    int cnt = 0;
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        for(int j = i+1;j<n;j++) {
            if(vec[i].f == vec[j].f) {
                done[i] = done[j] = true;
                cnt++;
                ans[j] = vec[j].s;
                if(used[vec[j].s])
                    return cout<<"NO", 0;
                used[vec[j].s]++;
            }
        }
        if(done[i]) {
            if(used[vec[i].s])
                    return cout<<"NO", 0;
            used[vec[i].s]++;
            ans[i] = vec[i].s;
            cnt++;
        }
    }
    map<string,int> mapping;
    map<int,string> revMap;
    BipGraph g(n,N);
    int c = 0;
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        if(!used[vec[i].f]) {
            int x = mapping[vec[i].f];
            if(!x)
                mapping[vec[i].f] = ++c, x = c, revMap[c] = vec[i].f;
            g.addEdge(i+1,x);
        }
        if(!used[vec[i].s]) {
            int y = mapping[vec[i].s];
            if(!y)
                mapping[vec[i].s] = ++c, y = c, revMap[c] = vec[i].s;
            g.addEdge(i+1,y);
        }
    }
    int x = g.hopcroftKarp();
    if(x + cnt != n)
        return cout<<"NO",0;
    for(int i = 1;i<=n;i++)
        if(g.pairU[i])
            ans[i-1] = revMap[g.pairU[i]];
    cout<<"YES"<<endl;
    for(string s : ans)
        cout<<s<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
using namespace std;
typedef vector<vector<int> > vvi;
typedef long long ll;
const int N = 3333, infi = 1e9;

int main()
{
    int n;
    cin>>n;
    vector<pair<string,string> > vec;
    for(int i = 1;i<=n;i++) {
        string a,b, aa, bb;
        cin>>a>>b;
        aa = a.substr(0,3), bb = a.substr(0,2) + b.substr(0,1);
        vec.push_back(make_pair(aa,bb));
    }
    map<string,int> used;
    vector<bool> done(n,false);
    vector<string> ans(n,"");
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        for(int j = i+1;j<n;j++) {
            if(vec[i].f == vec[j].f) {
                done[i] = done[j] = true;
                ans[j] = vec[j].s;
                if(used[vec[j].s])
                    return cout<<"NO", 0;
                used[vec[j].s]++;
            }
        }
        if(done[i]) {
            if(used[vec[i].s])
                    return cout<<"NO", 0;
            used[vec[i].s]++;
            ans[i] = vec[i].s;
        }
    }
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        if(!used[vec[i].s]) {
            ans[i] = vec[i].s, used[vec[i].s]++;
        } else if(used[vec[i].f]) {
            return cout<<"NO", 0;
        } else {
            ans[i] = vec[i].f, used[vec[i].f]++;
        }
    }
    cout<<"YES"<<endl;
    for(string s : ans)
        cout<<s<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
using namespace std;
typedef vector<vector<int> > vvi;
typedef long long ll;
const int N = 3333, infi = 1e9;

int main()
{
    int n;
    cin>>n;
    vector<pair<string,string> > vec;
    for(int i = 1;i<=n;i++) {
        string a,b, aa, bb;
        cin>>a>>b;
        aa = a.substr(0,3), bb = a.substr(0,2) + b.substr(0,1);
        vec.push_back(make_pair(aa,bb));
    }
    map<string,int> used, dont;
    vector<bool> done(n,false);
    vector<string> ans(n,"");
    for(int i = 0;i<n;i++) {
        for(int j = i+1;j<n;j++) {
            if(vec[i].f == vec[j].f) {
                done[i] = done[j] = true;
                if(used[vec[i].s])
                    return cout<<"NO", 0;
                used[vec[i].s]++;
                dont[vec[i].f]++;
                ans[i] = vec[i].s;
                if(used[vec[j].s])
                    return cout<<"NO", 0;
                used[vec[j].s]++;
                dont[vec[j].f]++;
                ans[j] = vec[j].s;
            }
        }
    }
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        if(used[vec[i].f] || dont[vec[i].f]) {
            if(used[vec[i].s])
                return cout<<"NO", 0;
            else
                ans[i] = vec[i].s, used[vec[i].s]++;
        } else {
            ans[i] = vec[i].f, used[vec[i].f]++;
        }
    }
    cout<<"YES"<<endl;
    for(string s : ans)
        cout<<s<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
using namespace std;
typedef vector<vector<int> > vvi;
typedef long long ll;
const int N = 3333, infi = 1e9;

int main()
{
    int n;
    cin>>n;
    vector<pair<string,string> > vec;
    for(int i = 1;i<=n;i++) {
        string a,b, aa, bb;
        cin>>a>>b;
        aa = a.substr(0,3), bb = a.substr(0,2) + b.substr(0,1);
        vec.push_back(make_pair(aa,bb));
    }
    map<string,int> used, dont;
    vector<bool> done(n,false);
    vector<string> ans(n,"");
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        for(int j = i+1;j<n;j++) {
            if(vec[i].f == vec[j].f) {
                done[i] = done[j] = true;
                ans[j] = vec[j].s;
                if(used[vec[j].s])
                    return cout<<"NO", 0;
                used[vec[j].s]++;
                dont[vec[j].f]++;
            }
        }
        if(done[i]) {
            if(used[vec[i].s])
                    return cout<<"NO", 0;
            used[vec[i].s]++;
            dont[vec[i].f]++;
            ans[i] = vec[i].s;
        }
    }
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        if(used[vec[i].f] || dont[vec[i].f]) {
            if(used[vec[i].s]) {
                if(vec[0].f == "KQC")
                        assert(false);
                return cout<<"NO", 0;
            } else
                ans[i] = vec[i].s, used[vec[i].s]++, dont[vec[i].f]++;
        } else {
            ans[i] = vec[i].f, used[vec[i].f]++;
        }
    }
    cout<<"YES"<<endl;
    for(string s : ans)
        cout<<s<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
using namespace std;
typedef vector<vector<int> > vvi;
typedef long long ll;
const int N = 3333, infi = 1e9;

int main()
{
    int n;
    cin>>n;
    vector<pair<string,string> > vec;
    for(int i = 1;i<=n;i++) {
        string a,b, aa, bb;
        cin>>a>>b;
        aa = a.substr(0,3), bb = a.substr(0,2) + b.substr(0,1);
        vec.push_back(make_pair(aa,bb));
    }
    map<string,int> used, dont;
    vector<bool> done(n,false);
    vector<string> ans(n,"");
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        for(int j = i+1;j<n;j++) {
            if(vec[i].f == vec[j].f) {
                done[i] = done[j] = true;
                ans[j] = vec[j].s;
                if(used[vec[j].s])
                    return cout<<"NO", 0;
                used[vec[j].s]++;
                dont[vec[j].f]++;
            }
        }
        if(done[i]) {
            if(used[vec[i].s])
                    return cout<<"NO", 0;
            used[vec[i].s]++;
            dont[vec[i].f]++;
            ans[i] = vec[i].s;
        }
    }
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        if(used[vec[i].f] || dont[vec[i].f]) {
            if(used[vec[i].s])
                return cout<<"NO", 0;
            else
                ans[i] = vec[i].s, used[vec[i].s]++;
        } else {
            ans[i] = vec[i].f, used[vec[i].f]++;
        }
    }
    cout<<"YES"<<endl;
    for(string s : ans)
        cout<<s<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
using namespace std;
typedef vector<vector<int> > vvi;
typedef long long ll;
const int N = 3333, infi = 1e9;

int main()
{
    int n;
    cin>>n;
    vector<pair<string,string> > vec;
    for(int i = 1;i<=n;i++) {
        string a,b, aa, bb;
        cin>>a>>b;
        aa = a.substr(0,3), bb = a.substr(0,2) + b.substr(0,1);
        vec.push_back(make_pair(aa,bb));
    }
    map<string,int> used, dont;
    vector<bool> done(n,false);
    vector<string> ans(n,"");
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        for(int j = i+1;j<n;j++) {
            if(vec[i].f == vec[j].f) {
                done[i] = done[j] = true;
                ans[j] = vec[j].s;
                if(used[vec[j].s])
                    return cout<<"NO", 0;
                used[vec[j].s]++;
                dont[vec[j].f]++;
            }
        }
        if(done[i]) {
            if(used[vec[i].s])
                    return cout<<"NO", 0;
            used[vec[i].s]++;
            dont[vec[i].f]++;
            ans[i] = vec[i].s;
        }
    }
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        if(!used[vec[i].s]) {
            ans[i] = vec[i].s, used[vec[i].s]++;
        } else if(dont[vec[i].f]) {
            return cout<<"NO", 0;
        } else {
            ans[i] = vec[i].f, used[vec[i].f]++;
        }
    }
    cout<<"YES"<<endl;
    for(string s : ans)
        cout<<s<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
using namespace std;
typedef vector<vector<int> > vvi;
typedef long long ll;
const int N = 3333, infi = 1e9;

int main()
{
    int n;
    cin>>n;
    vector<pair<string,string> > vec;
    for(int i = 1;i<=n;i++) {
        string a,b, aa, bb;
        cin>>a>>b;
        aa = a.substr(0,3), bb = a.substr(0,2) + b.substr(0,1);
        vec.push_back(make_pair(aa,bb));
    }
    map<string,int> used, dont;
    vector<bool> done(n,false);
    vector<string> ans(n,"");
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        for(int j = i+1;j<n;j++) {
            if(vec[i].f == vec[j].f) {
                done[i] = done[j] = true;
                ans[j] = vec[j].s;
                if(used[vec[j].s])
                    return cout<<"NO", 0;
                used[vec[j].s]++;
                dont[vec[j].f]++;
            }
        }
        if(done[i]) {
            if(used[vec[i].s]) {
                    if(vec[0].f == "KQC")
                        assert(false);
                    return cout<<"NO", 0;
            }
            used[vec[i].s]++;
            dont[vec[i].f]++;
            ans[i] = vec[i].s;
        }
    }
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        if(used[vec[i].f] || dont[vec[i].f]) {
            if(used[vec[i].s])
                return cout<<"NO", 0;
            else
                ans[i] = vec[i].s, used[vec[i].s]++, dont[vec[i].f]++;
        } else {
            ans[i] = vec[i].f, used[vec[i].f]++;
        }
    }
    cout<<"YES"<<endl;
    for(string s : ans)
        cout<<s<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
using namespace std;
typedef vector<vector<int> > vvi;
typedef long long ll;
const int N = 3333, infi = 1e9;

int main()
{
    int n;
    cin>>n;
    vector<pair<string,string> > vec;
    for(int i = 1;i<=n;i++) {
        string a,b, aa, bb;
        cin>>a>>b;
        aa = a.substr(0,3), bb = a.substr(0,2) + b.substr(0,1);
        vec.push_back(make_pair(aa,bb));
    }
    map<string,int> used;
    vector<bool> done(n,false);
    vector<string> ans(n,"");
    for(int i = 0;i<n;i++) {
        for(int j = i+1;j<n;j++) {
            if(vec[i].f == vec[j].f) {
                done[i] = done[j] = true;
                if(used[vec[i].s])
                    return cout<<"NO", 0;
                used[vec[i].s]++;
                used[vec[i].f]++;
                ans[i] = vec[i].s;
                if(used[vec[j].s])
                    return cout<<"NO", 0;
                used[vec[j].s]++;
                used[vec[j].f]++;
                ans[j] = vec[j].s;
            }
        }
    }
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        if(used[vec[i].f]) {
            if(used[vec[i].s])
                return cout<<"NO", 0;
            else
                ans[i] = vec[i].s, used[vec[i].s]++;
        } else {
            ans[i] = vec[i].f;
            used[vec[i].f]++;
        }
    }
    cout<<"YES"<<endl;
    for(string s : ans)
        cout<<s<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
using namespace std;
typedef vector<vector<int> > vvi;
typedef long long ll;
const int N = 3333, infi = 1e9;

int main()
{
    int n;
    cin>>n;
    vector<pair<string,string> > vec;
    for(int i = 1;i<=n;i++) {
        string a,b, aa, bb;
        cin>>a>>b;
        aa = a.substr(0,3), bb = a.substr(0,2) + b.substr(0,1);
        vec.push_back(make_pair(aa,bb));
    }
    map<string,int> used, dont;
    vector<bool> done(n,false);
    vector<string> ans(n,"");
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        for(int j = i+1;j<n;j++) {
            if(vec[i].f == vec[j].f) {
                done[i] = done[j] = true;
                ans[j] = vec[j].s;
                if(used[vec[j].s])
                    return cout<<"NO", 0;
                used[vec[j].s]++;
                dont[vec[j].f]++;
            }
        }
        if(done[i]) {
            if(used[vec[i].s]) {
                    assert(false);
                    return cout<<"NO", 0;
            }
            used[vec[i].s]++;
            dont[vec[i].f]++;
            ans[i] = vec[i].s;
        }
    }
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        if(used[vec[i].f] || dont[vec[i].f]) {
            if(used[vec[i].s])
                return cout<<"NO", 0;
            else
                ans[i] = vec[i].s, used[vec[i].s]++, dont[vec[i].f]++;
        } else {
            ans[i] = vec[i].f, used[vec[i].f]++;
        }
    }
    cout<<"YES"<<endl;
    for(string s : ans)
        cout<<s<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
using namespace std;
typedef vector<vector<int> > vvi;
typedef long long ll;
const int N = 3333, infi = 1e9;

int main()
{
    int n;
    cin>>n;
    vector<pair<string,string> > vec;
    for(int i = 1;i<=n;i++) {
        string a,b, aa, bb;
        cin>>a>>b;
        aa = a.substr(0,3), bb = a.substr(0,2) + b.substr(0,1);
        vec.push_back(make_pair(aa,bb));
    }
    map<string,int> used, dont;
    vector<bool> done(n,false);
    vector<string> ans(n,"");
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        for(int j = i+1;j<n;j++) {
            if(vec[i].f == vec[j].f) {
                done[i] = done[j] = true;
                ans[j] = vec[j].s;
                if(used[vec[j].s])
                    return cout<<"NO", 0;
                used[vec[j].s]++;
                dont[vec[j].f]++;
            }
        }
        if(done[i]) {
            if(used[vec[i].s])
                    return cout<<"NO", 0;
            used[vec[i].s]++;
            dont[vec[i].f]++;
            ans[i] = vec[i].s;
        }
    }
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        if(used[vec[i].f]) {
            if(used[vec[i].s])
                return cout<<"NO", 0;
            else
                ans[i] = vec[i].s, used[vec[i].s]++, dont[vec[i].f]++;
        } else {
            ans[i] = vec[i].f, used[vec[i].f]++;
        }
    }
    cout<<"YES"<<endl;
    for(string s : ans)
        cout<<s<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
using namespace std;
typedef vector<vector<int> > vvi;
typedef long long ll;
const int N = 3333, infi = 1e9;

int main()
{
    int n;
    cin>>n;
    vector<pair<string,string> > vec;
    for(int i = 1;i<=n;i++) {
        string a,b, aa, bb;
        cin>>a>>b;
        aa = a.substr(0,3), bb = a.substr(0,2) + b.substr(0,1);
        vec.push_back(make_pair(aa,bb));
    }
    map<string,int> used, dont;
    vector<bool> done(n,false);
    vector<string> ans(n,"");
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        for(int j = i+1;j<n;j++) {
            if(vec[i].f == vec[j].f) {
                done[i] = done[j] = true;
                ans[i] = vec[i].s;
                if(used[vec[j].s])
                    return cout<<"NO", 0;
                used[vec[j].s]++;
                dont[vec[j].f]++;
                ans[j] = vec[j].s;
            }
        }
        if(done[i]) {
            if(used[vec[i].s])
                    return cout<<"NO", 0;
            used[vec[i].s]++;
            dont[vec[i].f]++;
            ans[i] = vec[i].s;
        }
    }
    for(int i = 0;i<n;i++) {
        if(done[i])
            continue;
        if(used[vec[i].f] || dont[vec[i].f]) {
            if(used[vec[i].s])
                return cout<<"NO", 0;
            else
                ans[i] = vec[i].s, used[vec[i].s]++;
        } else {
            ans[i] = vec[i].f, used[vec[i].f]++;
        }
    }
    cout<<"YES"<<endl;
    for(string s : ans)
        cout<<s<<endl;
    return 0;
}


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

typedef pair<int,int> ii;
typedef pair<ii,int> pii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pii> vpii;
typedef long long int ll;
typedef unsigned long long int ull;

#define mi 1000000007
#define rep(i,a,b) for(i=a;i<b;i++)
#define repv(i,a,b) for(i=b-1;i>=a;i--)
#define pr(arr,n) rep(i,0,n) cout<<arr[i]<<" "; cout<<endl;
#define pr1(arr,n) rep(i,1,n+1) cout<<arr[i]<<" "; cout<<endl;
#define inf INT_MAX
#define gc getchar_unlocked
#define PB push_back
#define MP make_pair
#define fi first
#define se second
#define SET(a,b) memset(a,b,sizeof(a))
#define MAX 500005
#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

int mult(int x,int y)
{
  ll ans,x1=(ll)x,y1=(ll)y;
  ans=(x1*y1)%mi;
  return (int)ans;
}
int gcd(int a,int b) { return b==0 ? a : gcd (b,a%b);}
int lcm(int a,int b) { return a*(b/gcd(a,b));}

ll pow1(ll a,ll b)
{
  ll ans=1;
  while(b>0)
    {
      if(b&1) ans=(ans*a)%mi;
      a=(a*a)%mi; b>>=1;
    }
  return ans;
}
int n;
pair<string,pair<string,int> > arr[1005];
int f[10005];
bool change(int ind)
{
  if(f[ind]) return false;
  arr[ind].fi[2]=arr[ind].se.fi[0];
  f[ind]=1;
  return true;
}
bool check()
{
  bool ok=true;
  int i,j=1;
  arr[n+1]=MP("###",MP("#",n+1));
  rep(i,1,n+1)
    {
      if(arr[i].fi!=arr[i+1].fi)
	{
	  if(j<i)
	    {
	      while(j<=i)
		{
		  change(j);
		  j++;
		}
	    }
	  j=i+1;
	}
    }
  while(ok)
    {
      ok=false;
      rep(i,1,n+1)
	{
	  rep(j,i+1,n+1)
	    {
	      if(arr[i].fi==arr[j].fi)
		{
		  bool tmp=(change(i)|| change(j));
		  if(!tmp) return false;
		  ok=true;
		}
	    }
	}
    }
  rep(i,1,n+1)
    rep(j,i+1,n+1)
    if(arr[i].fi==arr[j].fi)
      return false;
  return true;
}
string ans[1005];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int i,j,k;
  cin>>n;
  string s1,s2;
  rep(i,1,n+1)
    {
      cin>>s1>>s2;
      arr[i].fi=s1.substr(0,3);
      arr[i].se.fi=s2[0];
      arr[i].se.se=i;
    }
  sort(arr+1,arr+n+1);
  if(!check())
    cout<<"NO"<<endl;
  else
    {
      cout<<"YES"<<endl;
      rep(i,1,n+1)
	ans[arr[i].se.se]=arr[i].fi;
      rep(i,1,n+1)
	cout<<ans[i]<<endl;
    }
  return 0;
}


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

typedef pair<int,int> ii;
typedef pair<ii,int> pii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pii> vpii;
typedef long long int ll;
typedef unsigned long long int ull;

#define mi 1000000007
#define rep(i,a,b) for(i=a;i<b;i++)
#define repv(i,a,b) for(i=b-1;i>=a;i--)
#define pr(arr,n) rep(i,0,n) cout<<arr[i]<<" "; cout<<endl;
#define pr1(arr,n) rep(i,1,n+1) cout<<arr[i]<<" "; cout<<endl;
#define inf INT_MAX
#define gc getchar_unlocked
#define PB push_back
#define MP make_pair
#define fi first
#define se second
#define SET(a,b) memset(a,b,sizeof(a))
#define MAX 500005
#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

int mult(int x,int y)
{
  ll ans,x1=(ll)x,y1=(ll)y;
  ans=(x1*y1)%mi;
  return (int)ans;
}
int gcd(int a,int b) { return b==0 ? a : gcd (b,a%b);}
int lcm(int a,int b) { return a*(b/gcd(a,b));}

ll pow1(ll a,ll b)
{
  ll ans=1;
  while(b>0)
    {
      if(b&1) ans=(ans*a)%mi;
      a=(a*a)%mi; b>>=1;
    }
  return ans;
}
map<string,int> m;
map<int,string> rev;
int rank[100005];
pair<string,string> arr[1005];
vector<vector<pair<string,int> > > v;
set<string> s;
string ans[1005];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n,i,j;
  si(n); v.resize(n+2);
  string s1,s2;
  int cnt=0;
  rep(i,1,n+1)
    {
      char ch1[25],ch2[25];
      cin>>s1>>s2;
      arr[i].fi=s1.substr(0,3);
      arr[i].se=s1.substr(0,2);
      arr[i].se+=s2[0];
      s1=arr[i].fi; s2=arr[i].se;
      if(m.find(s1)==m.end())
	{
	  m[s1]=cnt;
	  rev[cnt++]=s1;
	}
      v[m[s1]].PB(MP(s2,i));
    }
  rep(i,0,cnt)
    {
      s1=rev[i];
      if(v[i].size()==1)
	{
	  s2=v[i][0].fi;
	  if(s.find(s1)!=s.end() && s.find(s2)!=s.end())
	    {
	      cout<<"NO"<<endl;
	      return 0;
	    }
	  else if(s.find(s1)==s.end())
	    {
	      s.insert(s1);
	      ans[v[i][0].se]=s1;
	    }
	  else
	    {
	      s.insert(s2);
	      ans[v[i][0].se]=s2;
	    }
	}
      else
	{
	  sort(v[i].begin(),v[i].end());
	  rep(j,0,v[i].size()-1)
	    {
	      if(v[i][j]==v[i][j+1])
		{
		  cout<<"NO"<<endl;
		  return 0;
		}
	    }
	  rep(j,0,v[i].size())
	    {
	      int idx=v[i][j].se;
	      s2=v[i][j].fi;
	      if(s.find(s2)!=s.end())
		{
		  cout<<"NO"<<endl;
		  return 0;
		}
	      ans[idx]=s2;
	      s.insert(s2);
	    }
	}
    }
  cout<<"YES"<<endl;
  rep(i,1,n+1)
    cout<<ans[i]<<endl;
  return 0;
}


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

typedef pair<int,int> ii;
typedef pair<ii,int> pii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pii> vpii;
typedef long long int ll;
typedef unsigned long long int ull;

#define mi 1000000007
#define rep(i,a,b) for(i=a;i<b;i++)
#define repv(i,a,b) for(i=b-1;i>=a;i--)
#define pr(arr,n) rep(i,0,n) cout<<arr[i]<<" "; cout<<endl;
#define pr1(arr,n) rep(i,1,n+1) cout<<arr[i]<<" "; cout<<endl;
#define inf INT_MAX
#define gc getchar_unlocked
#define PB push_back
#define MP make_pair
#define fi first
#define se second
#define SET(a,b) memset(a,b,sizeof(a))
#define MAX 500005
#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

int mult(int x,int y)
{
  ll ans,x1=(ll)x,y1=(ll)y;
  ans=(x1*y1)%mi;
  return (int)ans;
}
int gcd(int a,int b) { return b==0 ? a : gcd (b,a%b);}
int lcm(int a,int b) { return a*(b/gcd(a,b));}

ll pow1(ll a,ll b)
{
  ll ans=1;
  while(b>0)
    {
      if(b&1) ans=(ans*a)%mi;
      a=(a*a)%mi; b>>=1;
    }
  return ans;
}
map<string,int> m;
map<int,string> rev;
pair<string,string> arr[1005];
vector<vector<pair<string,int> > > v;
set<string> s;
string ans[1005];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n,i,j;
  cin>>n; v.resize(n+2);
  string s1,s2;
  int cnt=0;
  rep(i,1,n+1)
    {
      char ch1[25],ch2[25];
      cin>>s1>>s2;
      arr[i].fi=s1.substr(0,3);
      arr[i].se=s1.substr(0,2);
      arr[i].se+=s2[0];
      s1=arr[i].fi; s2=arr[i].se;
      if(m.find(s1)==m.end())
	{
	  m[s1]=cnt;
	  rev[cnt++]=s1;
	}
      v[m[s1]].PB(MP(s2,i));
    }
  rep(i,0,cnt)
    {
      s1=rev[i];
      if(v[i].size()==1)
	{
	  s2=v[i][0].fi;
	  if(s.find(s1)!=s.end() && s.find(s2)!=s.end())
	    {
	      cout<<"NO"<<endl;
	      return 0;
	    }
	  else if(s.find(s1)==s.end())
	    {
	      s.insert(s1);
	      ans[v[i][0].se]=s1;
	    }
	  else
	    {
	      s.insert(s2);
	      ans[v[i][0].se]=s2;
	    }
	}
      else
	{
	  sort(v[i].begin(),v[i].end());
	  rep(j,0,v[i].size()-1)
	    {
	      if(v[i][j]==v[i][j+1])
		{
		  cout<<"NO"<<endl;
		  return 0;
		}
	    }
	  rep(j,0,v[i].size())
	    {
	      int idx=v[i][j].se;
	      s2=v[i][j].fi;
	      if(s.find(s2)!=s.end())
		{
		  cout<<"NO"<<endl;
		  return 0;
		}
	      ans[idx]=s2;
	      s.insert(s2);
	    }
	}
    }
  cout<<"YES"<<endl;
  rep(i,1,n+1)
    cout<<ans[i]<<endl;
  return 0;
}


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

typedef pair<int,int> ii;
typedef pair<ii,int> pii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pii> vpii;
typedef long long int ll;
typedef unsigned long long int ull;

#define mi 1000000007
#define rep(i,a,b) for(i=a;i<b;i++)
#define repv(i,a,b) for(i=b-1;i>=a;i--)
#define pr(arr,n) rep(i,0,n) cout<<arr[i]<<" "; cout<<endl;
#define pr1(arr,n) rep(i,1,n+1) cout<<arr[i]<<" "; cout<<endl;
#define inf INT_MAX
#define gc getchar_unlocked
#define PB push_back
#define MP make_pair
#define fi first
#define se second
#define SET(a,b) memset(a,b,sizeof(a))
#define MAX 500005
#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

int mult(int x,int y)
{
  ll ans,x1=(ll)x,y1=(ll)y;
  ans=(x1*y1)%mi;
  return (int)ans;
}
int gcd(int a,int b) { return b==0 ? a : gcd (b,a%b);}
int lcm(int a,int b) { return a*(b/gcd(a,b));}

ll pow1(ll a,ll b)
{
  ll ans=1;
  while(b>0)
    {
      if(b&1) ans=(ans*a)%mi;
      a=(a*a)%mi; b>>=1;
    }
  return ans;
}
map<string,int> m;
map<int,string> rev;
pair<string,string> arr[1005];
vector<vector<pair<string,int> > > v;
set<string> s;
string ans[1005];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n,i,j;
  cin>>n; v.resize(n+2);
  string s1,s2;
  int cnt=0;
  rep(i,1,n+1)
    {
      char ch1[25],ch2[25];
      cin>>s1>>s2;
      arr[i].fi=s1.substr(0,3);
      arr[i].se=s1.substr(0,2);
      arr[i].se+=s2[0];
      s1=arr[i].fi; s2=arr[i].se;
      if(m.find(s1)==m.end())
	{
	  m[s1]=cnt;
	  rev[cnt++]=s1;
	}
      v[m[s1]].PB(MP(s2,i));
    }
  rep(i,0,cnt)
    {
      s1=rev[i];
      if(v[i].size()==1)
	continue;
      sort(v[i].begin(),v[i].end());
      rep(j,0,v[i].size()-1)
	{
	  if(v[i][j]==v[i][j+1])
	    {
	      cout<<"NO"<<endl;
	      return 0;
	    }
	}
      rep(j,0,v[i].size())
	{
	  int idx=v[i][j].se;
	  s2=v[i][j].fi;
	  if(s.find(s2)!=s.end())
	    {
	      cout<<"NO"<<endl;
	      return 0;
	    }
	  ans[idx]=s2;
	  s.insert(s2);
	}
    }
  rep(i,0,cnt)
    {
      if(v[i].size()!=1) continue;
      s1=rev[i];
      s2=v[i][0].fi;
      if(s.find(s1)!=s.end() && s.find(s2)!=s.end())
	{
	  cout<<"NO"<<endl;
	  return 0;
	}
      else if(s.find(s1)==s.end())
	{
	  s.insert(s1);
	  ans[v[i][0].se]=s1;
	}
      else
	{
	  s.insert(s2);
	  ans[v[i][0].se]=s2;
	}
    }
  cout<<"YES"<<endl;
  rep(i,1,n+1)
    cout<<ans[i]<<endl;
  return 0;
}


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

typedef pair<int,int> ii;
typedef pair<ii,int> pii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pii> vpii;
typedef long long int ll;
typedef unsigned long long int ull;

#define mi 1000000007
#define rep(i,a,b) for(i=a;i<b;i++)
#define repv(i,a,b) for(i=b-1;i>=a;i--)
#define pr(arr,n) rep(i,0,n) cout<<arr[i]<<" "; cout<<endl;
#define pr1(arr,n) rep(i,1,n+1) cout<<arr[i]<<" "; cout<<endl;
#define inf INT_MAX
#define gc getchar_unlocked
#define PB push_back
#define MP make_pair
#define fi first
#define se second
#define SET(a,b) memset(a,b,sizeof(a))
#define MAX 500005
#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

int mult(int x,int y)
{
  ll ans,x1=(ll)x,y1=(ll)y;
  ans=(x1*y1)%mi;
  return (int)ans;
}
int gcd(int a,int b) { return b==0 ? a : gcd (b,a%b);}
int lcm(int a,int b) { return a*(b/gcd(a,b));}

ll pow1(ll a,ll b)
{
  ll ans=1;
  while(b>0)
    {
      if(b&1) ans=(ans*a)%mi;
      a=(a*a)%mi; b>>=1;
    }
  return ans;
}
map<string,int> m;
map<int,string> rev;
pair<string,string> arr[1005];
vector<vector<pair<string,int> > > v;
set<string> s;
string ans[1005];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n,i,j;
  cin>>n; v.resize(n+2);
  string s1,s2;
  int cnt=0;
  rep(i,1,n+1)
    {
      char ch1[25],ch2[25];
      cin>>s1>>s2;
      arr[i].fi=s1.substr(0,3);
      arr[i].se=s1.substr(0,2);
      arr[i].se+=s2[0];
      s1=arr[i].fi; s2=arr[i].se;
      if(m.find(s1)==m.end())
	{
	  m[s1]=cnt;
	  rev[cnt++]=s1;
	}
      v[m[s1]].PB(MP(s2,i));
    }
  rep(i,0,cnt)
    {
      s1=rev[i];
      if(v[i].size()==1)
	continue;
      sort(v[i].begin(),v[i].end());
      rep(j,0,v[i].size()-1)
	{
	  if(v[i][j]==v[i][j+1])
	    {
	      cout<<"NO"<<endl;
	      return 0;
	    }
	}
      rep(j,0,v[i].size())
	{
	  int idx=v[i][j].se;
	  s2=v[i][j].fi;
	  if(s.find(s2)!=s.end())
	    {
	      cout<<"NO"<<endl;
	      return 0;
	    }
	  ans[idx]=s2;
	  s.insert(s2);
	}
    }
  rep(i,0,cnt)
    {
      if(v[i].size()!=1) continue;
      s2=v[i][0].fi;
      if(s.find(s1)!=s.end() && s.find(s2)!=s.end())
	{
	  cout<<"NO"<<endl;
	  return 0;
	}
      else if(s.find(s1)==s.end())
	{
	  s.insert(s1);
	  ans[v[i][0].se]=s1;
	}
      else
	{
	  s.insert(s2);
	  ans[v[i][0].se]=s2;
	}
    }
  cout<<"YES"<<endl;
  rep(i,1,n+1)
    cout<<ans[i]<<endl;
  return 0;
}


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

typedef pair<int,int> ii;
typedef pair<ii,int> pii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pii> vpii;
typedef long long int ll;
typedef unsigned long long int ull;

#define mi 1000000007
#define rep(i,a,b) for(i=a;i<b;i++)
#define repv(i,a,b) for(i=b-1;i>=a;i--)
#define pr(arr,n) rep(i,0,n) cout<<arr[i]<<" "; cout<<endl;
#define pr1(arr,n) rep(i,1,n+1) cout<<arr[i]<<" "; cout<<endl;
#define inf INT_MAX
#define gc getchar_unlocked
#define PB push_back
#define MP make_pair
#define fi first
#define se second
#define SET(a,b) memset(a,b,sizeof(a))
#define MAX 500005
#define gu getchar
#define pu putchar
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define TRACE

#ifdef TRACE
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

#else

#define trace1(x)
#define trace2(x, y)
#define trace3(x, y, z)
#define trace4(a, b, c, d)
#define trace5(a, b, c, d, e)
#define trace6(a, b, c, d, e, f)

#endif

int mult(int x,int y)
{
  ll ans,x1=(ll)x,y1=(ll)y;
  ans=(x1*y1)%mi;
  return (int)ans;
}
int gcd(int a,int b) { return b==0 ? a : gcd (b,a%b);}
int lcm(int a,int b) { return a*(b/gcd(a,b));}

ll pow1(ll a,ll b)
{
  ll ans=1;
  while(b>0)
    {
      if(b&1) ans=(ans*a)%mi;
      a=(a*a)%mi; b>>=1;
    }
  return ans;
}
map<string,int> m;
map<int,string> rev;
pair<string,string> arr[1005];
vector<vector<pair<string,int> > > v;
set<string> s;
string ans[1005];
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n,i,j;
  si(n); v.resize(n+2);
  string s1,s2;
  int cnt=0;
  rep(i,1,n+1)
    {
      char ch1[25],ch2[25];
      cin>>s1>>s2;
      arr[i].fi=s1.substr(0,3);
      arr[i].se=s1.substr(0,2);
      arr[i].se+=s2[0];
      s1=arr[i].fi; s2=arr[i].se;
      if(m.find(s1)==m.end())
	{
	  m[s1]=cnt;
	  rev[cnt++]=s1;
	}
      v[m[s1]].PB(MP(s2,i));
    }
  rep(i,0,cnt)
    {
      s1=rev[i];
      if(v[i].size()==1)
	{
	  s2=v[i][0].fi;
	  if(s.find(s1)!=s.end() && s.find(s2)!=s.end())
	    {
	      cout<<"NO"<<endl;
	      return 0;
	    }
	  else if(s.find(s1)==s.end())
	    {
	      s.insert(s1);
	      ans[v[i][0].se]=s1;
	    }
	  else
	    {
	      s.insert(s2);
	      ans[v[i][0].se]=s2;
	    }
	}
      else
	{
	  sort(v[i].begin(),v[i].end());
	  rep(j,0,v[i].size()-1)
	    {
	      if(v[i][j]==v[i][j+1])
		{
		  cout<<"NO"<<endl;
		  return 0;
		}
	    }
	  rep(j,0,v[i].size())
	    {
	      int idx=v[i][j].se;
	      s2=v[i][j].fi;
	      if(s.find(s2)!=s.end())
		{
		  cout<<"NO"<<endl;
		  return 0;
		}
	      ans[idx]=s2;
	      s.insert(s2);
	    }
	}
    }
  cout<<"YES"<<endl;
  rep(i,1,n+1)
    cout<<ans[i]<<endl;
  return 0;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

bool adeleted[1000], bdeleted[1000];

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

    string a[1000], b[1000], x[1000], y[1000];
    int n;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
        a[i] = x[i].substr(0, 3);
        b[i] = x[i].substr(0, 2) + y[0];
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (i != j && a[i] == a[j])
                adeleted[j] = adeleted[i] = 1;

    for (int i = 0; i < n; i++)
        if (adeleted[i])
            for (int j = 0; j < n; j++)
                if (i != j)
                {
                    if (a[j] == b[i])
                        adeleted[j] = 1;
                    if (b[j] == b[i])
                        bdeleted[j] = 1;
                    if (adeleted[j] && bdeleted[j])
                    {
                        cout << "NO" << endl;
                        return 0;
                    }
                }

     for (int i = 0; i < n; i++)
        if (bdeleted[i])
            for (int j = 0; j < n; j++)
                if (i != j)
                {
                    if (a[j] == a[i])
                        adeleted[j] = 1;
                    if (b[j] == a[i])
                        bdeleted[j] = 1;
                    if (adeleted[j] && bdeleted[j])
                    {
                        cout << "NO" << endl;
                        return 0;
                    }
                }

    cout << "YES" << endl;
    for (int i = 0; i < n; i++)
        if (adeleted[i] == 0)
            cout << a[i] << " " << x[i] + " " + y[i] << endl;
        else
            cout << b[i] << " " << x[i] + " " + y[i] << endl;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <queue>

using namespace std;

bool adeleted[1000], bdeleted[1000];
queue <int> q;

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

    string a[1000], b[1000], x, y;
    int n;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        a[i] = x.substr(0, 3);
        b[i] = x.substr(0, 2) + y[0];
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (i != j && a[i] == a[j])
            {
                if (!adeleted[j])
                    q.push(j);
                if (!adeleted[i])
                    q.push(i);
                adeleted[j] = adeleted[i] = 1;
            }

    while (!q.empty())
    {
        int v = q.front(); q.pop();
        string str;
        if (adeleted[v] == 0)
            str = a[v];
        else
            str = b[v];
        for (int i = 0; i < n; i++)
            if (i != v)
            {
                if (!adeleted[i] && a[i] == str)
                {
                    adeleted[i] = 1;
                    q.push(i);
                }
                if (!bdeleted[i] && b[i] == str)
                {
                    bdeleted[i] = 1;
                    q.push(i);
                }
                if (adeleted[i] && bdeleted[i])
                {
                    cout << "NO" << endl;
                    return 0;
                }
            }
    }

    cout << "YES" << endl;
    for (int i = 0; i < n; i++)
        if (adeleted[i] == 0)
            cout << a[i] << endl;
        else
            cout << b[i] << endl;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

bool adeleted[1000], bdeleted[1000];

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

    string a[1000], b[1000], x, y;
    int n;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        a[i] = x.substr(0, 3);
        b[i] = x.substr(0, 2) + y[0];
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (i != j && a[i] == a[j])
                adeleted[j] = adeleted[i] = 1;

    for (int i = 0; i < n; i++)
        if (adeleted[i])
            for (int j = 0; j < n; j++)
                if (i != j)
                {
                    if (a[j] == b[i])
                        adeleted[j] = 1;
                    if (b[j] == b[i])
                        bdeleted[j] = 1;
                    if (adeleted[j] && bdeleted[j])
                    {
                        cout << "NO" << endl;
                        return 0;
                    }
                }

     for (int i = 0; i < n; i++)
        if (bdeleted[i])
            for (int j = 0; j < n; j++)
                if (i != j)
                {
                    if (a[j] == a[i])
                        adeleted[j] = 1;
                    if (b[j] == a[i])
                        bdeleted[j] = 1;
                    if (adeleted[j] && bdeleted[j])
                    {
                        cout << "NO" << endl;
                        return 0;
                    }
                }

    cout << "YES" << endl;
    for (int i = 0; i < n; i++)
        if (adeleted[i] == 0)
            cout << a[i] << endl;
        else
            cout << b[i] << endl;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

bool adeleted[1000], bdeleted[1000];

int main()
{
    string a[1000], b[1000], x, y;
    int n;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        a[i] = x.substr(0, 3);
        b[i] = x.substr(0, 2) + y[0];
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (i != j && a[i] == a[j])
                adeleted[j] = 1;

    for (int i = 0; i < n; i++)
        if (adeleted[i])
            for (int j = 0; j < n; j++)
                if (i != j)
                {
                    if (a[j] == b[i])
                        adeleted[j] = 1;
                    if (b[j] == b[i])
                        bdeleted[j] = 1;
                    if (adeleted[j] && bdeleted[j])
                    {
                        cout << "NO" << endl;
                        return 0;
                    }
                }

    for (int i = 0; i < n; i++)
        if (bdeleted[i])
            for (int j = 0; j < n; j++)
                if (i != j)
                {
                    if (b[j] == a[i])
                        bdeleted[j] = 1;
                    if (adeleted[j] && bdeleted[j])
                    {
                        cout << "NO" << endl;
                        return 0;
                    }
                }

    cout << "YES" << endl;
    for (int i = 0; i < n; i++)
        if (adeleted[i] == 0)
            cout << a[i] << endl;
        else
            cout << b[i] << endl;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

bool adeleted[1000], bdeleted[1000];

int main()
{
    string a[1000], b[1000], x, y;
    int n;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        a[i] = x.substr(0, 3);
        b[i] = x.substr(0, 2) + y[0];
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (i != j && a[i] == a[j])
                adeleted[j] = adeleted[i] = 1;

    for (int i = 0; i < n; i++)
        if (adeleted[i])
            for (int j = 0; j < n; j++)
                if (i != j)
                {
                    if (a[j] == b[i])
                        adeleted[j] = 1;
                    if (b[j] == b[i])
                        bdeleted[j] = 1;
                    if (adeleted[j] && bdeleted[j])
                    {
                        cout << "NO" << endl;
                        return 0;
                    }
                }

    cout << "YES" << endl;
    for (int i = 0; i < n; i++)
        if (adeleted[i] == 0)
            cout << a[i] << endl;
        else
            cout << b[i] << endl;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

bool adeleted[1000], bdeleted[1000];

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

    string a[1000], b[1000], x, y;
    int n;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        a[i] = x.substr(0, 3);
        b[i] = x.substr(0, 2) + y[0];
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (i != j && a[i] == a[j])
                adeleted[j] = adeleted[i] = 1;

    for (int i = 0; i < n; i++)
        if (adeleted[i])
            for (int j = 0; j < n; j++)
                if (i != j)
                {
                    if (a[j] == b[i])
                        adeleted[j] = 1;
                    if (b[j] == b[i])
                        bdeleted[j] = 1;
                    if (adeleted[j] && bdeleted[j])
                    {
                        cout << "NO" << endl;
                        return 0;
                    }
                }

     for (int i = 0; i < n; i++)
        if (bdeleted[i])
            for (int j = 0; j < n; j++)
                if (i != j)
                {
                    if (a[j] == a[i])
                        adeleted[j] = 1;
                    if (b[j] == a[i])
                        bdeleted[j] = 1;
                    if (adeleted[j] && bdeleted[j])
                    {
                        cout << "NO" << endl;
                        return 0;
                    }
                }

    cout << "YES" << endl;
    for (int i = 0; i < n; i++)
        if (adeleted[i] == 0)
            cout << a[i] << endl;
        else
            cout << b[i] << endl;
}


#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

bool adeleted[1000], bdeleted[1000];

int main()
{
    string a[1000], b[1000], x, y;
    int n;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x >> y;
        a[i] = x.substr(0, 3);
        b[i] = x.substr(0, 2) + y[0];
    }

    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            if (i != j && a[i] == a[j])
                adeleted[j] = 1;

    for (int i = 0; i < n; i++)
        if (adeleted[i])
            for (int j = 0; j < n; j++)
                if (i != j)
                {
                    if (a[j] == b[i])
                        adeleted[j] = 1;
                    if (b[j] == b[i])
                        bdeleted[j] = 1;
                    if (adeleted[j] && bdeleted[j])
                    {
                        cout << "NO" << endl;
                        return 0;
                    }
                }

    cout << "YES" << endl;
    for (int i = 0; i < n; i++)
        if (adeleted[i] == 0)
            cout << a[i] << endl;
        else
            cout << b[i] << endl;
}


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

map<string, int> m1;
map<string, int> m;

bool cmp(string &a, string & b) {
    int x = m.find(a)!=m.end();
    int y = m.find(b)!=m.end();
    return x > y;
}

int main(int argc, const char **argv) {
    if(argc>=2) {
        freopen(argv[1], "r", stdin);
        //freopen(argv[2], "w", stdout);
    }
    int n;
    cin >> n;
    map<string, vector<pair<string, string>>> v2;
    vector<pair<string, string>> v;
    vector<string> v0;

    map<string, string> alter;

    for(int i = 0 ; i < n ; i++) {
        string s1, s2;
        cin >> s1 >> s2;
        v.push_back({s1, s2});
        v2[s1.substr(0,3)].push_back({s1, s2});
        m1[s1.substr(0,3)]++;
    }
    vector<pair<string,int>> z(m1.begin(), m1.end());
    sort(z.begin(), z.end(), [] (pair<string,int>a ,pair<string,int> b) {return a.second >  b.second;} );

    map<pair<string, string>, string> ans;

    for(auto u:m1) {
        auto key = u.first;
        auto c = u.second;
        if (c > 1) {
            assert(key!="NJF");
            for(auto u:v2[key]) {
                string t = u.first.substr(0,2);
                t += u.second[0];
                if (m.find( t ) != m.end()) {
                    cout << "NO" << endl;
                    return 0;
                }
                ans[{u.first, u.second}] = t;
                m[t];
            }
        }
        else {
            v0.push_back(key);
        }
    }
    sort(v0.begin(), v0.end(), cmp);

    for(auto u1:v0) {
        for(auto u2:v2[u1]) {
            auto t = u2.first.substr(0, 2);
            auto t1 = t + u2.first[2], t2 = t + u2.second[0];
            if (m.find(t1) != m.end()) {
                if (m.find(t2)!=m.end()) {
                    cout << "NO" << endl;
                    return 0;
                }
                m[t2];
                ans[{u2.first, u2.second}] = t2;
            }
            else {
                ans[{u2.first, u2.second}] = t1; m[t1];

            }
        }
    }
    cout << "YES" << endl;
//    assert(ans.size()==n);
    for(auto u:v) {
        cout << ans[u] << endl;
    }

}


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

map<string, int> m1;
map<string, int> m;

bool cmp(string &a, string & b) {
    int x = m.find(a)!=m.end();
    int y = m.find(b)!=m.end();
    return x > y;
}

int main(int argc, const char **argv) {
    if(argc>=2) {
        freopen(argv[1], "r", stdin);
        //freopen(argv[2], "w", stdout);
    }
    int n;
    cin >> n;
    map<string, vector<pair<string, string>>> v2;
    vector<pair<string, string>> v;
    vector<string> v0;

    map<string, string> alter;

    for(int i = 0 ; i < n ; i++) {
        string s1, s2;
        cin >> s1 >> s2;
        v.push_back({s1, s2});
        v2[s1.substr(0,3)].push_back({s1, s2});
        m1[s1.substr(0,3)]++;
    }
    vector<pair<string,int>> z(m1.begin(), m1.end());
    sort(z.begin(), z.end(), [] (pair<string,int>a ,pair<string,int> b) {return a.second >  b.second;} );

    map<pair<string, string>, string> ans;

    for(auto u:m1) {
        auto key = u.first;
        auto c = u.second;
        if (c > 1) {
            for(auto u:v2[key]) {
                string t = u.first.substr(0,2);
                t += u.second[0];
                if (m.find( t ) != m.end()) {
                    cout << "NO" << endl;
                    return 0;
                }
                ans[{u.first, u.second}] = t;
                m[t];
            }
        }
        else {
            v0.push_back(key);
        }
    }
    sort(v0.begin(), v0.end(), cmp);
    for(auto u1:v0) {
        for(auto u2:v2[u1]) {
            auto t = u2.first.substr(0, 2);
            auto t1 = t + u2.first[2], t2 = t + u2.second[0];
            if (m.find(t1) != m.end()) {
                if (m.find(t2)!=m.end()) {
                    cout << "NO" << endl;
                    return 0;
                }
                m[t2];
                ans[{u2.first, u2.second}] = t2;
            }
            else {
                ans[{u2.first, u2.second}] = t1;
            }
        }
    }
    cout << "YES" << endl;
    for(auto u:v) {
        cout << ans[u] << endl;
    }

}


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

map<string, int> m1;
map<string, int> m;

bool cmp(string &a, string & b) {
    int x = m.find(a)!=m.end();
    int y = m.find(b)!=m.end();
    return x > y;
}

int main(int argc, const char **argv) {
    if(argc>=2) {
        freopen(argv[1], "r", stdin);
        //freopen(argv[2], "w", stdout);
    }
    int n;
    cin >> n;
    map<string, vector<pair<string, string>>> v2;
    vector<pair<string, string>> v;
    vector<string> v0;

    map<string, string> alter;

    for(int i = 0 ; i < n ; i++) {
        string s1, s2;
        cin >> s1 >> s2;
        v.push_back({s1, s2});
        v2[s1.substr(0,3)].push_back({s1, s2});
        m1[s1.substr(0,3)]++;
    }
    vector<pair<string,int>> z(m1.begin(), m1.end());
    sort(z.begin(), z.end(), [] (pair<string,int>a ,pair<string,int> b) {return a.second >  b.second;} );

    map<pair<string, string>, string> ans;

    int p = -1;

    for(auto u:m1) {
        auto key = u.first;
        auto c = u.second;
        if (c > 1) {
            for(auto u:v2[key]) {
                string t = u.first.substr(0,2);
                t += u.second[0];
                if (m.find( t ) != m.end()) {
                    cout << "NO" << endl;
                    return 0;
                }
                ans[{u.first, u.second}] = t;
                m[t];
            }
        }
        else {
            v0.push_back(key);
        }
    }
    sort(v0.begin(), v0.end(), cmp);

    vector<string> vx;
    while (v0.size() != p && v0.size() > 0) {
        vx.clear();
        p = v0.size();
        for(auto u1:v0) {
            int f= 0;
            if (f) {
                vx.push_back(u1);
            }
            else
            for(auto u2:v2[u1]) {
                auto t = u2.first.substr(0, 2);
                auto t1 = t + u2.first[2], t2 = t + u2.second[0];
                if (m.find(t1) != m.end()) {
                    if (m.find(t2)!=m.end()) {
                        cout << "NO" << endl;
                        return 0;
                    }
                    m[t2];
                    ans[{u2.first, u2.second}] = t2;
                }
                else {
                    f = 1;
                    vx.push_back(u1);
                }
            }
        }
        sort(vx.begin(), vx.end(), cmp);
//        cerr << p << endl;
//        for(auto u:vx) {
//            cout << u << " ";
//        }
//        cerr << vx.size() << endl;
//        cerr << endl;
        v0 = vx;
    }

    for(auto u1:v0) {
        int f= 0;
        if (f) {
            vx.push_back(u1);
        }
        else
            for(auto u2:v2[u1]) {
                auto t = u2.first.substr(0, 2);
                auto t1 = t + u2.first[2], t2 = t + u2.second[0];
                if (m.find(t1) != m.end()) {
                    if (m.find(t2)!=m.end()) {
                        cout << "NO" << endl;
                        return 0;
                    }
                    m[t2];
                    ans[{u2.first, u2.second}] = t2;
                }
                else {
                    ans[{u2.first, u2.second}] = t1;
                    m[t1];
                }
            }
    }

    cout << "YES" << endl;
//    assert(ans.size()==n);
    for(auto u:v) {
        cout << ans[u] << endl;
    }

}


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

int main(int argc, const char **argv) {
    if(argc>=2) {
        freopen(argv[1], "r", stdin);
        //freopen(argv[2], "w", stdout);
    }
    int n;
    cin >> n;
    map<string, int> m1, vis;
    set<string> m;
    map<string, vector<pair<string, string>>> v2;
    vector<pair<string, string>> v;

    map<string, string> alter;

    for(int i = 0 ; i < n ; i++) {
        string s1, s2;
        cin >> s1 >> s2;
        v.push_back({s1, s2});
        v2[s1.substr(0,3)].push_back({s1, s2});
        m1[s1.substr(0,3)]++;
    }
    vector<pair<string,int>> z(m1.begin(), m1.end());
    sort(z.begin(), z.end(), [] (pair<string,int>a ,pair<string,int> b) {return a.second >  b.second;} );
    for(auto u:m1) {
        auto key = u.first;
        auto c = u.second;
        if (c > 1) {
            for(auto u:v2[key]) {
                string t = u.first.substr(0,2);
                t += u.second[0];
                if (m.find( t ) != m.end()) {
                    cout << "NO" << endl;
                    return 0;
                }
                m.insert(t);
            }
        }
        else {
            if (m.find(key) == m.end()) {
                m.insert(key);
                auto u = v2[key][0];
                string t = u.first.substr(0,2);
                t += u.second[0];
                alter[key] = t;
                continue;
            }
            else {
                auto u = v2[key][0];
                string t = u.first.substr(0,2);
                t += u.second[0];
                if (m.find(t) == m.end()) {
                    m.insert(t);
                    continue;
                }
                vis.clear();
                auto x = alter[t];
                while (m.find(alter[x])!= m.end()) {
                    if (vis[x]) {
                        cout << "NO" << endl;
                        return 0;
                    }
                    vis[x]++;
                    x = alter[x];
                }
                if (x.length() < 3) {
                    cout << "NO" << endl;
                    return 0;
                }
                m.insert(x);
            }
        }
    }
    cout << "YES" << endl;
    for(auto u:m) {
        cout << u << endl;
    }

}


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

map<string, int> m1;
map<string, int> m;

bool cmp(string &a, string & b) {
    int x = m.find(a)!=m.end();
    int y = m.find(b)!=m.end();
    return x > y;
}

int main(int argc, const char **argv) {
    if(argc>=2) {
        freopen(argv[1], "r", stdin);
        //freopen(argv[2], "w", stdout);
    }
    int n;
    cin >> n;
    map<string, vector<pair<string, string>>> v2;
    vector<pair<string, string>> v;
    vector<string> v0;

    map<string, string> alter;

    for(int i = 0 ; i < n ; i++) {
        string s1, s2;
        cin >> s1 >> s2;
        v.push_back({s1, s2});
        v2[s1.substr(0,3)].push_back({s1, s2});
        m1[s1.substr(0,3)]++;
    }
    vector<pair<string,int>> z(m1.begin(), m1.end());
    sort(z.begin(), z.end(), [] (pair<string,int>a ,pair<string,int> b) {return a.second >  b.second;} );

    map<pair<string, string>, string> ans;

    for(auto u:m1) {
        auto key = u.first;
        auto c = u.second;
        if (c > 1) {
            assert(key!="NJF");
            for(auto u:v2[key]) {
                string t = u.first.substr(0,2);
                t += u.second[0];
                if (m.find( t ) != m.end()) {
                    cout << "NO" << endl;
                    return 0;
                }
                ans[{u.first, u.second}] = t;
                m[t];
            }
        }
        else {
            v0.push_back(key);
        }
    }
    sort(v0.begin(), v0.end(), cmp);

    for(auto u1:v0) {
        for(auto u2:v2[u1]) {
            auto t = u2.first.substr(0, 2);
            auto t1 = t + u2.first[2], t2 = t + u2.second[0];
            if (m.find(t1) != m.end()) {
                if (m.find(t2)!=m.end()) {
                    cout << "NO" << endl;
                    return 0;
                }
                m[t2];
                ans[{u2.first, u2.second}] = t2;
            }
            else {
                ans[{u2.first, u2.second}] = t1;
            }
        }
    }
    cout << "YES" << endl;
//    assert(ans.size()==n);
    for(auto u:v) {
        cout << ans[u] << endl;
    }

}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
string a[2000];
string b[2000];
string ans[2000];
string s1[2000];
string s2[2000];
map<string, int> mp1;
map<string, int> mp2;
map<string, int> anss;

int main()
{
    int n;
    cin >> n;
    scanf("\n");
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cin >> b[i];
        s1[i].pb(a[i][0]);
        s1[i].pb(a[i][1]);
        s1[i].pb(a[i][2]);
        s2[i].pb(a[i][0]);
        s2[i].pb(a[i][1]);
        s2[i].pb(b[i][0]);
        if(mp1[s1[i]] && mp2[s2[i]]){
            printf("NO");
            return 0;
        }
        mp1[s1[i]]++;
        mp2[s2[i]]++;
    }
    for(int i = 0; i < n; i++){
        if(mp1[s1[i]] == 1 && mp2[s2[i]] != 1){
            ans[i] = s1[i];
            if(anss[s1[i]] == 0)ans[i] = s1[i];
            else{
                printf("NO");
                return 0;
            }
            anss[ans[i]] = 1;
        }
        else if(mp1[s1[i]] != 1 && mp2[s2[i]] == 1){
            ans[i] = s2[i];

            if(anss[s2[i]] == 0)ans[i] = s2[i];
            else{
                printf("NO");
                return 0;
            }
            anss[ans[i]] = 1;
        }
        else{
            if(anss[s1[i]] == 0)ans[i] = s1[i];
            else(anss[s1[i]] == 0)ans[i] = s2[i];
            else{
                printf("NO");
                return 0;
            }
        }
    }
    printf("YES\n");
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
string a[2000];
string b[2000];
string ans[2000];
string s1[2000];
string s2[2000];
map<string, int> mp1;
map<string, int> mp2;
map<string, int> anss;

int main()
{
    int n;
    cin >> n;
    scanf("\n");
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cin >> b[i];
        s1[i].pb(a[i][0]);
        s1[i].pb(a[i][1]);
        s1[i].pb(a[i][2]);
        s2[i].pb(a[i][0]);
        s2[i].pb(a[i][1]);
        s2[i].pb(b[i][0]);
        mp1[s1[i]]++;
        mp2[s2[i]]++;
    }
    for(int i = 0; i < n; i++){
        if(mp1[s1[i]] != 1){
            ans[i] = s2[i];
            if(anss[ans[i]] != 0){
                printf("NO\n");
                return 0;
            }
            else{
                anss[ans[i]] = 1;
            }
        }
    }
    vector<int> v;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(ans[i].size() == 0){
            if(anss[s1[i]] == 0){
                ans[i] = s1[i];
                anss[s1[i]] = 1;
                v.pb(i);
            }
            else if(anss[s2[i]] == 0){
                ans[i] = s2[i];
                if(anss[s2[i]] != 0){
                    printf("NO\n");
                    return 0;
                }
                else{
                    anss[s2[i]] = 1;
                }
            }
            else{
                if(v.empty()){
                    printf("NO\n");
                    return 0;
                }
                else{
                    i = v[cnt++];
                    anss[s1[i]] = 0;
                    for(int it = cnt - 1; it < v.size(); it++){
                        ans[it].resize(0);
                    }
                }
            }
        }
    }
    printf("YES\n");
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
string a[2000];
string b[2000];
string ans[2000];
string s1[2000];
string s2[2000];
map<string, int> mp1;
map<string, int> mp2;
map<string, int> anss;

int main()
{
    int n;
    cin >> n;
    scanf("\n");
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cin >> b[i];
        s1[i].pb(a[i][0]);
        s1[i].pb(a[i][1]);
        s1[i].pb(a[i][2]);
        s2[i].pb(a[i][0]);
        s2[i].pb(a[i][1]);
        s2[i].pb(b[i][0]);
        mp1[s1[i]]++;
        mp2[s2[i]]++;
    }
    for(int i = 0; i < n; i++){
        if(mp1[s1[i]] != 1){
            ans[i] = s2[i];
            if(anss[ans[i]] != 0){
                printf("NO\n");
                return 0;
            }
            else{
                anss[ans[i]] = 1;
            }
        }
    }
    vector<int> v;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(ans[i].size() == 0){
            if(anss[s1[i]] == 0){
                ans[i] = s1[i];
                anss[s1[i]] = 1;
                v.pb(i);
            }
            else if(anss[s2[i]] == 0){
                ans[i] = s2[i];
                if(anss[s2[i]] != 0){
                    printf("NO\n");
                    return 0;
                }
                else{
                    anss[s2[i]] = 1;
                }
            }
            else{
                if(v.empty()){
                    printf("NO\n");
                    return 0;
                }
                else{
                    i = v[cnt++] - 1;
                    anss[s1[i]] = 0;
                    for(int it = cnt - 1; it < v.size(); it++){
                        anss[ans[i]] = 0;
                        ans[it].resize(0);
                    }
                }
            }
        }
    }
    printf("YES\n");
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
set<string> ban;
set<string> use;
vector<string> ans;

int main()
{
    int n;
    cin >> n;
    scanf("\n");
    for(int i = 0; i < n; i++){
        string s1;
        string s2;
        cin >> s1 >> s2;
        string a = s1.substr(0, 3);
        string b = s1.substr(0, 2) + s2[0];
        if(use.count(b)){
            if(ban.count(a) || use.count(a)){
                puts("NO\n");
                return 0;
            }
        }
        else{
            ban.insert(a);
            use.insert(b);
            ans.pb(b);
        }
    }
    printf("YES\n");
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
set<string> ban;
set<string> use;
vector<string> ans;

int main()
{
    int n;
    cin >> n;
    scanf("\n");
    for(int i = 0; i < n; i++){
        string s1;
        string s2;
        cin >> s1 >> s2;
        string a = s1.substr(0, 3);
        string b = s1.substr(0, 2) + s2[0];
        if(use.count(b)){
            if(ban.count(a) || use.count(a)){
                puts("NO\n");
                return 0;
            }
            use.insert(a);
            ans.pb(a);
        }
        else{
            ban.insert(a);
            use.insert(b);
            ans.pb(b);
        }
    }
    printf("YES\n");
    for(int i = 0; i < ans.size(); i++){
        cout << ans[i] << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
string a[2000];
string b[2000];
string ans[2000];
string s1[2000];
string s2[2000];
map<string, int> mp1;
map<string, int> mp2;
map<string, int> anss;

int main()
{
    int n;
    cin >> n;
    scanf("\n");
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cin >> b[i];
        s1[i].pb(a[i][0]);
        s1[i].pb(a[i][1]);
        s1[i].pb(a[i][2]);
        s2[i].pb(a[i][0]);
        s2[i].pb(a[i][1]);
        s2[i].pb(b[i][0]);
        if(mp1[s1[i]] && mp2[s2[i]]){
            printf("NO");
            return 0;
        }
        mp1[s1[i]]++;
        mp2[s2[i]]++;
    }
    for(int i = 0; i < n; i++){
        if(mp1[s1[i]] == 1 && mp2[s2[i]] != 1){
            ans[i] = s1[i];
            mp2[s2[i]]--;
            if(anss[s1[i]] == 0)ans[i] = s1[i];
            else{
                printf("NO");
                return 0;
            }
            anss[ans[i]] = 1;
        }
        else if(mp1[s1[i]] != 1 && mp2[s2[i]] == 1){
            ans[i] = s2[i];
            if(anss[s2[i]] == 0)ans[i] = s2[i];
            else{
                printf("NO");
                return 0;
            }
            anss[ans[i]] = 1;
            anss[s1[i]] = 1;
        }
        else{
            if(anss[s1[i]] == 0){
                ans[i] = s1[i];
                anss[ans[i]] = 1;
                mp2[s2[i]]--;
            }
            else if(anss[s2[i]] == 0){
                ans[i] = s2[i];
                anss[ans[i]] = 1;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
    }
    printf("YES\n");
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
string a[2000];
string b[2000];
string ans[2000];
string s1[2000];
string s2[2000];
map<string, int> mp1;
map<string, int> mp2;
map<string, int> anss;

int main()
{
    int n;
    cin >> n;
    scanf("\n");
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cin >> b[i];
        s1[i].pb(a[i][0]);
        s1[i].pb(a[i][1]);
        s1[i].pb(a[i][2]);
        s2[i].pb(a[i][0]);
        s2[i].pb(a[i][1]);
        s2[i].pb(b[i][0]);
        mp1[s1[i]]++;
        mp2[s2[i]]++;
    }
    for(int i = 0; i < n; i++){
        if(mp1[s1[i]] != 1){
            ans[i] = s2[i];
            if(anss[ans[i]] != 0){
                printf("NO\n");
                return 0;
            }
            else{
                anss[ans[i]] = 1;
            }
        }
    }
    vector<int> v;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(ans[i].size() == 0){
            if(anss[s1[i]] == 0){
                ans[i] = s1[i];
                anss[s1[i]] = 1;
                v.pb(i);
            }
            else if(anss[s2[i]] == 0){
                ans[i] = s2[i];
                if(anss[s2[i]] != 0){
                    printf("NO\n");
                    return 0;
                }
                else{
                    anss[s2[i]] = 1;
                }
            }
            else{
                if(cnt == v.size()){
                    printf("NO\n");
                    return 0;
                }
                else{
                    //i = v[cnt++];
                    /*for(int it = cnt - 1; it < v.size(); it++){
                        anss[ans[it]] = 0;
                        ans[it].resize(0);
                    }*/
                    //i--;
                }
            }
        }
    }
    printf("YES\n");
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
string a[2000];
string b[2000];
string ans[2000];
string s1[2000];
string s2[2000];
map<string, int> mp1;
map<string, int> mp2;
map<string, int> anss;

int main()
{
    int n;
    cin >> n;
    scanf("\n");
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cin >> b[i];
        s1[i].pb(a[i][0]);
        s1[i].pb(a[i][1]);
        s1[i].pb(a[i][2]);
        s2[i].pb(a[i][0]);
        s2[i].pb(a[i][1]);
        s2[i].pb(b[i][0]);
        mp1[s1[i]]++;
        mp2[s2[i]]++;
    }
    for(int i = 0; i < n; i++){
        if(mp1[s1[i]] != 1){
            ans[i] = s2[i];
            if(anss[ans[i]] != 0){
                printf("NO\n");
                return 0;
            }
            else{
                anss[ans[i]] = 1;
            }
        }
    }
    queue<int> q;
    for(int i = 0; i < n; i++){
        if(ans[i].size() == 0){
            if(anss[s1[i]] == 0){
                ans[i] = s1[i];
                anss[s1[i]] = 1;
                q.push(i);
            }
            else if(anss[s2[i]] == 0){
                ans[i] = s2[i];
                if(anss[s2[i]] != 0){
                    printf("NO\n");
                    return 0;
                }
                else{
                    anss[s2[i]] = 1;
                }
            }
            else{
                if(q.empty()){
                    printf("NO\n");
                    return 0;
                }
                else{
                    i = q.front();
                    anss[s1[i]] = 0;
                    q.pop();
                }
            }
        }
    }
    printf("YES\n");
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
string a[2000];
string b[2000];
string ans[2000];
string s1[2000];
string s2[2000];
map<string, int> mp1;
map<string, int> mp2;
map<string, int> anss;

int main()
{
    int n;
    cin >> n;
    scanf("\n");
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cin >> b[i];
        s1[i].pb(a[i][0]);
        s1[i].pb(a[i][1]);
        s1[i].pb(a[i][2]);
        s2[i].pb(a[i][0]);
        s2[i].pb(a[i][1]);
        s2[i].pb(b[i][0]);
        if(mp1[s1[i]] && mp2[s2[i]]){
            printf("NO");
            return 0;
        }
        mp1[s1[i]]++;
        mp2[s2[i]]++;
    }
    for(int i = 0; i < n; i++){
        if(mp1[s1[i]] == 1 && mp2[s2[i]] != 1){
            ans[i] = s1[i];
            if(anss[s1[i]] == 0)ans[i] = s1[i];
            else{
                printf("NO");
                return 0;
            }
            anss[ans[i]] = 1;
        }
        else if(mp1[s1[i]] != 1 && mp2[s2[i]] == 1){
            ans[i] = s2[i];

            if(anss[s2[i]] == 0)ans[i] = s2[i];
            else{
                printf("NO");
                return 0;
            }
            anss[ans[i]] = 1;
        }
        else{
            if(anss[s1[i]] == 0)ans[i] = s1[i];
            else if(anss[s2[i]] == 0)ans[i] = s2[i];
            else{
                printf("NO");
                return 0;
            }
        }
    }
    printf("YES\n");
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
string a[2000];
string b[2000];
string ans[2000];
string s1[2000];
string s2[2000];
map<string, int> mp1;
map<string, int> mp2;
map<string, int> anss;

int main()
{
    int n;
    cin >> n;
    scanf("\n");
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cin >> b[i];
        s1[i].pb(a[i][0]);
        s1[i].pb(a[i][1]);
        s1[i].pb(a[i][2]);
        s2[i].pb(a[i][0]);
        s2[i].pb(a[i][1]);
        s2[i].pb(b[i][0]);
        mp1[s1[i]]++;
        mp2[s2[i]]++;
    }
    for(int i = 0; i < n; i++){
        if(mp1[s1[i]] != 1)ans[i] = s2[i];
        if(anss[ans[i]] != 0){
            printf("NO\n");
            return 0;
        }
        else{
            anss[ans[i]] = 1;
        }
    }
    for(int i = 0; i < n; i++){
        if(ans[i].size() == 0){
            if(anss[s1[i]] == 0)ans[i] = s1[i];
            else if(anss[s2[i]] == 0)ans[i] = s2[i];
            else{
                printf("NO\n");
                return 0;
            }
        }
    }
    printf("YES\n");
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
set<string> ban;
set<string> use;
vector<string> ans;

int main()
{
    int n;
    cin >> n;
    scanf("\n");
    for(int i = 0; i < n; i++){
        string s1;
        string s2;
        cin >> s1 >> s2;
        string a = s1.substr(0, 3);
        string b = s1.substr(0, 2) + s2[0];
        if(use.count(b)){
            if(ban.count(a) || use.count(a)){
                puts("NO\n");
                return 0;
            }
        }
        else{
            ban.insert(a);
            use.insert(b);
            ans.pb(b);
        }
    }
    printf("YES\n");
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
string a[2000];
string b[2000];
string ans[2000];
string s1[2000];
string s2[2000];
map<string, int> mp1;
map<string, int> mp2;
map<string, int> rep;

int main()
{
    int n;
    cin >> n;
    scanf("\n");
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cin >> b[i];
        s1[i].pb(a[i][0]);
        s1[i].pb(a[i][1]);
        s1[i].pb(a[i][2]);
        s2[i].pb(a[i][0]);
        s2[i].pb(a[i][1]);
        s2[i].pb(b[i][0]);
        mp1[s1[i]]++;
        mp2[s2[i]]++;
    }
    int cnt = 0, now = 0;
    for(int i = 0; i < n; i++){
        if(mp1[s1[i]] != 1){
            ans[i] = s2[i];
            if(rep[ans[i]] == 0){
                rep[ans[i]] = 1;
                cnt++, now++;
            }
            else{
                printf("NO\n");
                return 0;
            }
        }
    }
    do{
        now = cnt;
        for(int i = 0; i < n; i++){
            if(ans[i].size() == 0){
                if(rep[s1[i]] != 0){
                    ans[i] = s2[i];
                    cnt++;
                }
                if(rep[s1[i]] != 0 && rep[s2[i]] != 0){
                    printf("NO\n");
                    return 0;
                }
                rep[ans[i]] = 1;
            }
        }
    }while(now != cnt);
    for(int i = 0; i < n; i++){
        if(ans[i].size() == 0){
            ans[i] = s1[i];
        }
    }
    printf("YES\n");
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
string a[2000];
string b[2000];
string ans[2000];
string s1[2000];
string s2[2000];
map<string, int> mp1;
map<string, int> mp2;
map<string, int> anss;

int main()
{
    int n;
    cin >> n;
    scanf("\n");
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cin >> b[i];
        s1[i].pb(a[i][0]);
        s1[i].pb(a[i][1]);
        s1[i].pb(a[i][2]);
        s2[i].pb(a[i][0]);
        s2[i].pb(a[i][1]);
        s2[i].pb(b[i][0]);
        mp1[s1[i]]++;
        mp2[s2[i]]++;
    }
    for(int i = 0; i < n; i++){
        if(mp1[s1[i]] != 1){
            ans[i] = s2[i];
            if(anss[ans[i]] != 0){
                printf("NO\n");
                return 0;
            }
            else{
                anss[ans[i]] = 1;
            }
        }
    }
    for(int i = 0; i < n; i++){
        if(ans[i].size() == 0){
            if(anss[s1[i]] == 0)ans[i] = s1[i];
            else if(anss[s2[i]] == 0)ans[i] = s2[i];
            else{
                printf("NO\n");
                return 0;
            }
        }
    }
    printf("YES\n");
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
string a[2000];
string b[2000];
string ans[2000];
string s1[2000];
string s2[2000];
map<string, int> mp1;
map<string, int> mp2;
map<string, int> anss;

int main()
{
    int n;
    cin >> n;
    scanf("\n");
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cin >> b[i];
        s1[i].pb(a[i][0]);
        s1[i].pb(a[i][1]);
        s1[i].pb(a[i][2]);
        s2[i].pb(a[i][0]);
        s2[i].pb(a[i][1]);
        s2[i].pb(b[i][0]);
        if(mp1[s1[i]] && mp2[s2[i]]){
            printf("NO");
            return 0;
        }
        mp1[s1[i]]++;
        mp2[s2[i]]++;
    }
    for(int i = 0; i < n; i++){
        if(mp1[s1[i]] == 1 && mp2[s2[i]] != 1){
            ans[i] = s1[i];
            if(anss[s1[i]] == 0)ans[i] = s1[i];
            else{
                printf("NO");
                return 0;
            }
            anss[ans[i]] = 1;
        }
        else if(mp1[s1[i]] != 1 && mp2[s2[i]] == 1){
            ans[i] = s2[i];

            if(anss[s2[i]] == 0)ans[i] = s2[i];
            else{
                printf("NO");
                return 0;
            }
            anss[ans[i]] = 1;
        }
        else{
            if(anss[s1[i]] == 0)ans[i] = s1[i];
            else if(anss[s1[i]] == 0)ans[i] = s2[i];
            else{
                printf("NO");
                return 0;
            }
        }
    }
    printf("YES\n");
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
string a[2000];
string b[2000];
string ans[2000];
string s1[2000];
string s2[2000];
map<string, int> mp1;
map<string, int> mp2;
map<string, int> anss;

int main()
{
    int n;
    cin >> n;
    scanf("\n");
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cin >> b[i];
        s1[i].pb(a[i][0]);
        s1[i].pb(a[i][1]);
        s1[i].pb(a[i][2]);
        s2[i].pb(a[i][0]);
        s2[i].pb(a[i][1]);
        s2[i].pb(b[i][0]);
        mp1[s1[i]]++;
        mp2[s2[i]]++;
    }
    for(int i = 0; i < n; i++){
        if(mp1[s1[i]] != 1){
            ans[i] = s2[i];
            if(anss[ans[i]] != 0){
                printf("NO\n");
                return 0;
            }
            else{
                anss[ans[i]] = 1;
            }
        }
    }
    vector<int> v;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        if(ans[i].size() == 0){
            if(anss[s1[i]] == 0){
                ans[i] = s1[i];
                anss[s1[i]] = 1;
                v.pb(i);
            }
            else if(anss[s2[i]] == 0){
                ans[i] = s2[i];
                if(anss[s2[i]] != 0){
                    printf("NO\n");
                    return 0;
                }
                else{
                    anss[s2[i]] = 1;
                }
            }
            else{
                if(v.empty()){
                    printf("NO\n");
                    return 0;
                }
                else{
                    i = v[cnt++];
                    anss[s1[i]] = 0;
                    for(int it = cnt - 1; it < v.size(); it++){
                        anss[ans[i]] = 0;
                        ans[it].resize(0);
                    }
                    i--;
                }
            }
        }
    }
    printf("YES\n");
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <stack>
#include <sstream>
#include <queue>
#include <map>

using namespace std;
#define pb push_back
#define mk make_pair
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP1(i, n) for(int (i)=1;(i)<=(int)(n);(i)++)

template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
string a[2000];
string b[2000];
string ans[2000];
string s1[2000];
string s2[2000];
map<string, int> mp1;
map<string, int> mp2;
map<string, int> anss;

int main()
{
    int n;
    cin >> n;
    scanf("\n");
    for(int i = 0; i < n; i++){
        cin >> a[i];
        cin >> b[i];
        s1[i].pb(a[i][0]);
        s1[i].pb(a[i][1]);
        s1[i].pb(a[i][2]);
        s2[i].pb(a[i][0]);
        s2[i].pb(a[i][1]);
        s2[i].pb(b[i][0]);
        if(mp1[s1[i]] && mp2[s2[i]]){
            printf("NO");
            return 0;
        }
        mp1[s1[i]]++;
        mp2[s2[i]]++;
    }
    for(int i = 0; i < n; i++){
        if(mp1[s1[i]] == 1 && mp2[s2[i]] != 1){
            ans[i] = s1[i];
            if(anss[s1[i]] == 0)ans[i] = s1[i];
            else{
                printf("NO");
                return 0;
            }
            anss[ans[i]] = 1;
        }
        else if(mp1[s1[i]] != 1 && mp2[s2[i]] == 1){
            ans[i] = s2[i];

            if(anss[s2[i]] == 0)ans[i] = s2[i];
            else{
                printf("NO");
                return 0;
            }
            anss[ans[i]] = 1;
        }
        else{
            if(anss[s1[i]] == 0)ans[i] = s1[i];
            else ans[i] = s2[i];
        }
    }
    printf("YES\n");
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}