#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int p1, p2, n, p3, quantity;
  bool isPossible = true;
  map<int, string> mp1;
  map<int, int> mp2, mp3;
  map<int, int>::iterator it;
  vector<string> result;
  string str;
  cin >> quantity;
  mp1[0] = "S";
  mp2[0] = quantity;
  cin >> quantity;
  mp1[1] = "M";
  mp2[1] = quantity;
  cin >> quantity;
  mp1[2] = "L";
  mp2[2] = quantity;
  cin >> quantity;
  mp1[3] = "XL";
  mp2[3] = quantity;
  cin >> quantity;
  mp1[4] = "XXL";
  mp2[4] = quantity;
  cin >> quantity;
  mp1[5] = "XXXL";
  mp2[5] = quantity;
  cin >> n;
  vector<vector<string> > request(n);
  for (p1 = 0; p1 < n; p1++) {
    cin >> str;
    for (p2 = 0; p2 < str.size() && str[p2] != ','; p2++)
      ;
    request[p1].push_back(str.substr(0, p2));
    p2++;
    p3 = p2;
    while (p2 < str.size()) p2++;
    if (p2 != p3) request[p1].push_back(str.substr(p3, p2 - p3));
  }
  for (it = mp2.begin(); it != mp2.end(); it++) {
    for (p1 = 0; p1 < n && it->second > 0; p1++) {
      if (request[p1].size() > 1) continue;
      if (request[p1][0] == mp1[it->first]) {
        mp3[p1]++;
        it->second--;
      }
    }
    for (p1 = 0; p1 < n && it->second > 0; p1++) {
      if (request[p1].size() > 1 && request[p1][0] == mp1[it->first]) {
        request[p1].pop_back();
        mp3[p1]++;
        it->second--;
      } else if (request[p1].size() > 1 && request[p1][1] == mp1[it->first]) {
        request[p1].erase(request[p1].begin());
        mp3[p1]++;
        it->second--;
      }
    }
    for (; p1 < n; p1++) {
      if (request[p1].size() <= 1) continue;
      if (request[p1][0] == mp1[it->first])
        request[p1].erase(request[p1].begin());
      else if (request[p1][1] == mp1[it->first])
        request[p1].pop_back();
    }
  }
  for (p1 = 0; p1 < n; p1++)
    if (request[p1].size() > 1) isPossible = false;
  if (mp3.size() != n) isPossible = false;
  if (!isPossible) {
    cout << "NO";
  } else {
    cout << "YES" << endl;
    for (p1 = 0; p1 < n; p1++) cout << request[p1][0] << endl;
  }
  return 0;
}
