#include <bits/stdc++.h>
using namespace std;
template <typename T>
T getint() {
  T x = 0, p = 1;
  char ch;
  do {
    ch = getchar();
  } while (ch <= ' ');
  if (ch == '-') p = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * p;
}
mt19937 gen(std::chrono::system_clock::now().time_since_epoch().count());
template <typename T1, typename T2>
bool umin(T1 &x, const T2 &y) {
  if (x > y) return x = y, true;
  return false;
}
template <typename T1, typename T2>
bool umax(T1 &x, const T2 &y) {
  if (x < y) return x = y, true;
  return false;
}
const int maxn = (int)1e6 + 10;
const int inf = (int)1e9 + 5;
const int mod = (int)1e9 + 7;
const long long llinf = (long long)1e18 + 5;
const long double pi = acos(-1.0);
map<string, vector<int> > m;
string a[maxn], b[maxn];
string ans[maxn];
set<string> was;
int main() {
  int n;
  cin >> n;
  for (int(i) = (0); (i) < (n); ++(i)) {
    cin >> a[i] >> b[i];
    string x = a[i].substr(0, 3);
    m[x].push_back(i);
  }
  vector<int> q;
  for (auto x : m) {
    if (x.second.size() == 1) {
      q.push_back(x.second[0]);
      continue;
    }
    for (auto y : x.second) {
      string z = a[y].substr(0, 2);
      z += b[y][0];
      if (was.count(z)) {
        cout << "NO\n";
        return 0;
      }
      was.insert(z);
      ans[y] = z;
    }
  }
  bool have = true;
  while (have) {
    have = 0;
    for (int i : q) {
      if (ans[i].size() != 0) continue;
      string v = a[i].substr(0, 3);
      if (was.count(v)) {
        string z = a[i].substr(0, 2);
        z += b[i][0];
        if (was.count(z)) {
          cout << "NO\n";
          return 0;
        }
        was.insert(z);
        ans[i] = z;
        have = true;
        break;
      }
    }
  }
  for (int(i) = (0); (i) < (n); ++(i)) {
    if (ans[i] == "") ans[i] = a[i].substr(0, 3);
  }
  cout << "YES\n";
  for (int(i) = (0); (i) < (n); ++(i)) cout << ans[i] << endl;
  return 0;
}
