#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long Inf = 1e18 + 9;
const int N = 1001;
int n;
string s1[N], s2[N];
int d[N];
vector<int> v;
bool check() {
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      if (d[i] == 1 && d[j] == 1 && s1[i] == s1[j]) return false;
      if (d[i] == 2 && d[j] == 2 && s2[i] == s2[j]) return false;
      if (d[i] == 1 && d[j] == 2 && (s1[i] == s2[j] || s1[i] == s1[j]))
        return false;
      if (d[i] == 2 && d[j] == 1 && (s2[i] == s1[j] || s1[i] == s1[j]))
        return false;
    }
  return true;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string S1, S2;
    cin >> S1 >> S2;
    s1[i] = s1[i] + S1[0] + S1[1] + S1[2];
    s2[i] = s2[i] + S1[0] + S1[1] + S2[0];
  }
  for (int i = 0; i < n; i++) d[i] = 1;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      if (s1[i] == s1[j]) d[i] = d[j] = 2;
  for (int i = 0; i < n; i++)
    if (d[i] == 2) v.push_back(i);
  int i = 0;
  while (true) {
    int m = v.size();
    for (int j = 0; j < n; j++)
      for (int i1 = i; i1 < m; i1++)
        if (d[j] == 1 && s2[v[i1]] == s1[j]) {
          d[j] = 2;
          v.push_back(j);
        }
    i = m;
    if (i == (int)v.size()) break;
  }
  if (!check()) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  for (int i = 0; i < n; i++) {
    if (d[i] == 1)
      cout << s1[i] << endl;
    else
      cout << s2[i] << endl;
  }
  return 0;
}
