#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const long long int N = 1e5;
long long int mod = 1e9 + 7;
long long int dx[4] = {0, 0, +1, -1};
long long int dy[4] = {+1, -1, 0, 0};
void solve() {
  vector<pair<string, string> > vs;
  long long int n;
  cin >> n;
  for (long long int i = 0; i < n; i++) {
    string s, p;
    cin >> s >> p;
    string g1 = "", g2 = "";
    g1 += s[0];
    g1 += s[1];
    g1 += s[2];
    g2 += s[0];
    g2 += s[1];
    g2 += p[0];
    vs.push_back({g1, g2});
  }
  vector<string> wyn(n);
  vector<long long int> vis(n, 0);
  while (1) {
    for (long long int i = 0; i < n; i++)
      wyn[i] = (vis[i] ? vs[i].second : vs[i].first);
    sort((wyn).begin(), (wyn).end());
    string nax;
    long long int f = 0;
    for (long long int i = 1; i < n; i++) {
      if (wyn[i] == wyn[i - 1]) {
        nax = wyn[i];
        break;
      }
    }
    if ((long long int)nax.size() == 0) break;
    for (long long int i = 0; i < n; i++) {
      if (vs[i].first == nax && vis[i] == 0) {
        vis[i] = 1;
        f = 1;
      }
    }
    if (f == 0) {
      cout << "NO\n";
      return;
    }
  }
  cout << "YES\n";
  for (long long int i = 0; i < n; i++)
    cout << (vis[i] ? vs[i].second : vs[i].first) << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int t = 1;
  while (t--) solve();
  return 0;
}
