#include <bits/stdc++.h>
using namespace std;
const long double EPS = 0.1;
int n;
vector<string> name;
vector<string> city;
map<string, vector<int> > cnt;
map<string, int> numb;
set<string> used;
vector<int> bil;
int gl = 0;
vector<int> hertam;
vector<int> ans;
bool kun(int v) {
  if (bil[v] == gl) {
    return 0;
  }
  bil[v] = gl;
  string s = name[v].substr(0, 3);
  string t = name[v].substr(0, 2) + city[v][0];
  if (numb.find(s) != numb.end()) {
    if (hertam[numb[s]] == -1 || kun(hertam[numb[s]])) {
      ans[v] = 1;
      hertam[numb[s]] = v;
      return 1;
    }
  }
  if (numb.find(t) != numb.end()) {
    if (hertam[numb[t]] == -1 || kun(hertam[numb[t]])) {
      ans[v] = 2;
      hertam[numb[t]] = v;
      return 1;
    }
  }
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  name.resize(n), city.resize(n);
  for (int i = 0; i < n; ++i) {
    cin >> name[i] >> city[i];
    cnt[name[i].substr(0, 3)].push_back(i);
  }
  ans.resize(n, 0);
  for (auto v : cnt) {
    if (v.second.size() > 1) {
      for (auto u : v.second) {
        ans[u] = 2;
        if (used.find(name[u].substr(0, 2) + city[u][0]) == used.end()) {
          used.insert(name[u].substr(0, 2) + city[u][0]);
        } else {
          cout << "NO" << endl;
          return 0;
        }
      }
    }
  }
  string nname;
  for (int i = 0; i < n; ++i) {
    if (ans[i] == 0) {
      used.insert(name[i].substr(0, 3));
      used.insert(name[i].substr(0, 2) + city[i][0]);
    }
  }
  for (int i = 0; i < n; ++i) {
    if (ans[i] == 2) {
      if (used.find(name[i].substr(0, 2) + city[i][0]) != used.end()) {
        used.erase(used.find(name[i].substr(0, 2) + city[i][0]));
      }
    }
  }
  for (auto v : used) {
    numb[v] = numb.size() - 1;
  }
  hertam.resize(numb.size(), -1);
  bil.resize(n, 0);
  for (int i = 0; i < n; ++i) {
    if (ans[i] == 0) {
      ++gl;
      if (!kun(i)) {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  for (int i = 0; i < n; ++i) {
    if (ans[i] == 1) {
      cout << name[i].substr(0, 3) << endl;
    } else {
      cout << name[i].substr(0, 2) + city[i][0] << endl;
    }
  }
  return 0;
}
