#include <bits/stdc++.h>
std::string GetFirstOption(const std::pair<std::string, std::string> &pair) {
  return pair.first.substr(0, 3);
}
std::string GetSecondOption(const std::pair<std::string, std::string> &pair) {
  return pair.first.substr(0, 2) + pair.second.substr(0, 1);
}
bool GetClubNames(const std::vector<std::pair<std::string, std::string>> &raw,
                  std::map<std::string, int> &results) {
  int size = raw.size();
  std::map<std::string, std::set<int>> items;
  for (int i = 0; i < size; i++) {
    std::string first_opt = GetFirstOption(raw[i]);
    auto itr = items.find(first_opt);
    if (itr != items.end())
      itr->second.insert(i);
    else {
      items[first_opt] = std::set<int>({i});
    }
  }
  auto itr = items.begin();
  std::set<int> alone_items;
  for (; itr != items.end(); ++itr) {
    auto &index_set = itr->second;
    auto index_itr = index_set.begin();
    if (index_set.size() <= 1) {
      alone_items.insert(*index_itr);
      continue;
    }
    for (; index_itr != index_set.end(); ++index_itr) {
      std::string second_opt = GetSecondOption(raw[*index_itr]);
      if (results.find(second_opt) != results.end()) return false;
      results[second_opt] = *index_itr;
    }
  }
  while (!alone_items.empty()) {
    auto copy = alone_items;
    alone_items.clear();
    auto copy_itr = copy.begin();
    for (; copy_itr != copy.end(); ++copy_itr) {
      int index = *copy_itr;
      std::string first_opt = GetFirstOption(raw[index]);
      if (results.find(first_opt) == results.end()) {
        alone_items.insert(index);
      } else {
        std::string second_opt = GetSecondOption(raw[index]);
        if (results.find(second_opt) != results.end()) return false;
        results[second_opt] = index;
      }
    }
    if (alone_items.size() == copy.size()) break;
  }
  auto alone_itr = alone_items.begin();
  for (; alone_itr != alone_items.end(); ++alone_itr) {
    std::string first_opt = GetFirstOption(raw[*alone_itr]);
    results[first_opt] = *alone_itr;
  }
  return true;
}
int main() {
  std::vector<std::pair<std::string, std::string>> inputs;
  std::map<std::string, int> results;
  std::map<std::string, int> unchosenFirsts;
  std::map<std::string, int> chosenFirsts;
  int size = 0;
  std::cin >> size;
  char team[25];
  char hometown[25];
  for (int i = 0; i < size; i++) {
    std::cin >> team;
    std::cin >> hometown;
    inputs.push_back(std::make_pair(std::string(team), std::string(hometown)));
  }
  if (GetClubNames(inputs, results)) {
    std::cout << "YES" << std::endl;
    std::vector<std::string> sorted_result(size);
    auto itr = results.begin();
    for (; itr != results.end(); ++itr) {
      sorted_result[itr->second] = itr->first;
    }
    for (int i = 0; i < size; i++) std::cout << sorted_result[i] << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  return 0;
}
