#include <bits/stdc++.h>
using namespace std;
string get(string &a, string &b, int type) {
  string s1, s0;
  s1 += a[0];
  s1 += a[1];
  s1 += b[0];
  s0 += a[0];
  s0 += a[1];
  s0 += a[2];
  if (type == 1) return s1;
  return s0;
}
vector<vector<pair<int, int> > > g;
vector<int> used, mt, mt1;
vector<string> names[2];
map<string, int> all;
vector<int> part;
vector<int> part1;
vector<string> bck;
bool dfs(int v) {
  if (used[v]) return 0;
  used[v] = 1;
  for (auto to : g[v]) {
    if (to.second == 1) {
      if (mt[to.first] != -1 && bck[part[to.first]] == names[0][mt[to.first]])
        continue;
    } else {
      if (mt1[to.first] != -1) continue;
    }
    if (mt[to.first] == -1 || dfs(mt[to.first]) || mt1[to.first] == -1 ||
        dfs(mt1[to.first])) {
      if (to.second == 0) {
        mt[part1[to.first]] = v;
      } else {
        mt[to.first] = v;
      }
      if (to.second == 1) {
        mt1[part[to.first]] = v;
      } else {
        mt1[to.first] = v;
      }
      return 1;
    }
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  vector<pair<string, string> > v(n);
  names[0].resize(n);
  names[1].resize(n);
  for (int i = 0; i < n; i++) {
    string a, b;
    cin >> a >> b;
    v[i] = {a, b};
    names[0][i] = get(a, b, 0);
    names[1][i] = get(a, b, 1);
    all[names[0][i]] = 0;
    all[names[1][i]] = 0;
  }
  int m = 0;
  for (auto &it : all) {
    bck.push_back(it.first);
    it.second = m++;
  }
  part.resize(m);
  part1.resize(m);
  g.resize(n);
  for (int i = 0; i < n; i++) {
    part[all[names[1][i]]] = all[names[0][i]];
    part1[all[names[0][i]]] = all[names[1][i]];
    g[i].push_back({all[names[1][i]], 1});
    g[i].push_back({all[names[0][i]], 0});
  }
  mt.assign(m, -1);
  mt1.assign(m, -1);
  for (int v = 0; v < n; v++) {
    used.assign(n, 0);
    dfs(v);
  }
  vector<string> ans(n, "#");
  for (int i = 0; i < m; i++) {
    if (mt[i] == -1) continue;
    ans[mt[i]] = bck[i];
  }
  for (int i = 0; i < n; i++) {
    if (ans[i] == "#") {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  for (int i = 0; i < n; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}
