#include <bits/stdc++.h>
using namespace std;
int mapp(char a, char b, char c) {
  return (a - 'A') * 26 * 26 + (b - 'A') * 26 + (c - 'A');
}
int n;
char s[33];
struct team {
  int id, iden_1, iden_2;
  bool operator<(const team &k) const { return iden_1 < k.iden_1; }
};
team te[1005];
void pt(int x) {
  printf("%c", x + 'A');
  return;
}
void unmapp(int x) {
  pt(x / (26 * 26)), x %= (26 * 26);
  pt(x / 26), x %= 26;
  pt(x % 26);
  puts("");
  return;
}
int occupied[30000], res[1005], done[1005];
void gg() {
  printf("NO\n");
  exit(0);
}
bool check() {
  for (int i = (1); i <= (n); i++)
    if (!done[i]) return true;
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); i++) {
    scanf(" %s", s);
    char a, b, c, d;
    a = s[0], b = s[1], c = s[2];
    te[i].id = i;
    te[i].iden_1 = mapp(a, b, c);
    scanf(" %s", s);
    d = s[0];
    te[i].iden_2 = mapp(a, b, d);
  }
  sort(te + 1, te + n + 1);
  for (int i = (1); i <= (n); i++) {
    int pt = i;
    while (pt < n && te[pt + 1].iden_1 == te[i].iden_1) pt++;
    if (pt > i) {
      for (int j = (i); j <= (pt); j++) {
        if (occupied[te[j].iden_2]) gg();
        occupied[te[j].iden_2] = te[j].id;
        done[j] = true;
      }
      i = pt;
    }
  }
  while (check()) {
    bool dead = false;
    for (int i = (1); i <= (n); i++)
      if (!done[i] && occupied[te[i].iden_1]) {
        if (occupied[te[i].iden_2]) gg();
        occupied[te[i].iden_2] = te[i].id;
        done[i] = true;
        dead = true;
      }
    if (!dead) {
      for (int i = (1); i <= (n); i++)
        if (!done[i]) {
          occupied[te[i].iden_1] = te[i].id;
          done[i] = true;
        }
    }
  }
  for (int i = (0); i <= (29999); i++)
    if (occupied[i]) res[occupied[i]] = i;
  printf("YES\n");
  for (int i = (1); i <= (n); i++) unmapp(res[i]);
  return 0;
}
