#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > d, dr;
vector<int> topsort;
string s1[1000 + 5], s2[1000 + 5];
bool used[1000000 + 5];
void dfs(int v) {
  used[v] = true;
  for (auto i : d[v]) {
    if (!used[i]) dfs(i);
  }
  topsort.push_back(v);
}
int k = 0;
int comp[1000000 + 5];
void dfs_c(int v) {
  used[v] = true;
  comp[v] = k;
  for (auto i : dr[v]) {
    if (!used[i]) dfs_c(i);
  }
}
string ans[1000 + 5];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string t1, t2;
    cin >> t1 >> t2;
    s1[i] = "";
    s2[i] = "";
    s1[i] += t1[0];
    s1[i] += t1[1];
    s1[i] += t1[2];
    s2[i] += t1[0];
    s2[i] += t1[1];
    s2[i] += t2[0];
  }
  d.resize(n * 4);
  for (int i = 0; i < n; i++) {
    d[i].push_back(i + n * 3);
    d[i + n * 2].push_back(i + n);
    d[i + n].push_back(i + n * 2);
    d[i + n * 3].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (s1[i] == s1[j]) {
        d[i].push_back(j + n * 2);
        d[j].push_back(i + n * 2);
        d[i + n].push_back(j + n * 2);
        d[j].push_back(i + n * 3);
        d[j + n].push_back(i + n * 2);
        d[i].push_back(j + n * 3);
      }
      if (s2[i] == s2[j]) {
        d[i + n].push_back(j + n * 3);
        d[j + n].push_back(i + n * 3);
      }
      if (s1[i] == s2[j]) {
        d[i].push_back(j + n * 3);
        d[j + n].push_back(i + n * 2);
      }
      if (s2[i] == s1[j]) {
        d[i + n].push_back(j + n * 2);
        d[j].push_back(i + n * 3);
      }
    }
  }
  dr.resize(n * 4);
  for (int i = 0; i < n * 4; i++) {
    for (auto j : d[i]) {
      dr[j].push_back(i);
    }
  }
  for (int i = 0; i < n * 4; i++) {
    if (!used[i]) {
      dfs(i);
    }
  }
  reverse(topsort.begin(), topsort.end());
  for (int i = 0; i < n * 4; i++) {
    used[i] = false;
  }
  for (int i = 0; i < n * 4; i++) {
    if (!used[i]) {
      k++;
      dfs_c(i);
    }
  }
  for (int i = 0; i < n; i++) {
    if (comp[i] == comp[i + n * 2] || comp[i + n] == comp[i + n * 3]) {
      cout << "NO";
      return 0;
    }
    if (comp[i] > comp[i + n * 2])
      ans[i] = s1[i];
    else
      ans[i] = s2[i];
  }
  cout << "YES" << '\n';
  for (int i = 0; i < n; i++) {
    cout << ans[i] << '\n';
  }
}
