#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 200;
const long long lim = 2e9;
pair<string, string> a[N];
string s, s1, b[N];
set<string> v;
map<string, long long> m;
long long n, p[N], pisos, kol, k, x;
bool comp(long long i, long long j) { return a[i].first < a[j].first; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> s >> s1;
    a[i].first = s[0];
    a[i].first += s[1];
    a[i].first += s[2];
    a[i].second = s[0];
    a[i].second += s[1];
    a[i].second += s1[0];
    p[i] = i;
    m[a[i].second]++;
  }
  sort(p + 1, p + 1 + n, comp);
  k = 1;
  kol = 0;
  for (int i = 2; i <= n; i++) {
    if (a[p[i - 1]].first == a[p[i]].first) {
      if (k == 1) {
        b[p[i - 1]] = a[p[i - 1]].second;
        v.insert(b[p[i - 1]]);
        kol++;
      }
      b[p[i]] = a[p[i]].second;
      v.insert(b[p[i]]);
      kol++;
      k++;
    } else
      k = 1;
  }
  if (v.size() != kol) return cout << "NO", 0;
  for (int i = 1; i <= n; i++)
    if (b[i].empty()) {
      s = a[i].first;
      if (m[s] > 0) s = a[i].second;
      if (v.find(s) != v.end()) {
        s = a[i].second;
        if (v.find(s) != v.end()) return cout << "NO", 0;
      }
      v.insert(s);
      b[i] = s;
    }
  if (v.size() != n)
    while (1)
      ;
  cout << "YES"
       << "\n";
  for (int i = 1; i <= n; i++) {
    cout << b[i] << "\n";
  }
  return 0;
}
