#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
const int Mod = 1e9 + 7;
const int MaxN = 1e6 + 5;
struct node {
  string x, y;
  int id;
} a[2005];
map<string, bool> used;
string ans[2005];
int n;
struct cmp {
  bool operator()(node x, node y) { return used[x.x] < used[y.x]; }
};
bool cmp1(node p, node q) { return p.x < q.x; }
priority_queue<node, vector<node>, cmp> que, tmp;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    char s[30], t[30];
    scanf("%s %s", s, t);
    a[i].x += s[0], a[i].x += s[1], a[i].x += s[2];
    a[i].y += s[0], a[i].y += s[1], a[i].y += t[0];
    a[i].id = i;
  }
  sort(a + 1, a + 1 + n, cmp1);
  int flag = 1;
  for (int i = 1; i <= n && flag; i++) {
    if ((i > 1 && a[i].x == a[i - 1].x) || (i < n && a[i].x == a[i + 1].x)) {
      if (used[a[i].y])
        flag = 0;
      else
        ans[a[i].id] = a[i].y, used[a[i].y] = 1;
    } else
      que.push(a[i]);
  }
  while (!que.empty() && flag) {
    node now = que.top();
    que.pop();
    if (used[now.x]) {
      if (used[now.y])
        flag = 0;
      else
        ans[now.id] = now.y, used[now.y] = 1;
    } else
      ans[now.id] = now.x, used[now.x] = 1;
    while (!que.empty()) tmp.push(que.top()), que.pop();
    while (!tmp.empty()) que.push(tmp.top()), tmp.pop();
  }
  if (flag) {
    printf("YES\n");
    for (int i = 1; i <= n; i++)
      printf("%c%c%c\n", ans[i][0], ans[i][1], ans[i][2]);
  } else
    printf("NO\n");
  return 0;
}
