#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
vector<string> results(100001);
vector<pair<int, string> > wishes;
vector<pair<int, string> > S_M, M_L, L_XL, XL_XXL, XXL_XXXL;
bool compare(pair<int, string> a, pair<int, string> b) {
  if (a.second == "S,M") return false;
  if (a.second == "M,L") return b.second == "S,M";
  if (a.second == "L,XL") return b.second == "S,M" || b.second == "M,L";
  if (a.second == "XL,XXL") return b.second != "XXL,XXXL";
  return true;
}
int main() {
  int S = 0, M = 0, L = 0, XL = 0, XXL = 0, XXXL = 0;
  cin >> S >> M >> L >> XL >> XXL >> XXXL;
  map<string, int> sizes;
  sizes["S"] = S;
  sizes["M"] = M;
  sizes["L"] = L;
  sizes["XL"] = XL;
  sizes["XXL"] = XXL;
  sizes["XXXL"] = XXXL;
  int n;
  string s;
  cin >> n;
  unsigned long long xx = 0;
  for (int i = 0; i < n; i++) {
    cin >> s;
    int pos = s.find(",");
    if (pos == string::npos) {
      results[i] = s;
      if (sizes[s] > 0)
        sizes[s]--;
      else {
        cout << "NO";
        return 0;
      }
    } else {
      if (s == "S,M") S_M.push_back(make_pair(i, s));
      if (s == "M,L") M_L.push_back(make_pair(i, s));
      if (s == "L,XL") L_XL.push_back(make_pair(i, s));
      if (s == "XL,XXL") XL_XXL.push_back(make_pair(i, s));
      if (s == "XXL,XXXL") {
        XXL_XXXL.push_back(make_pair(i, s));
        xx++;
      }
    }
  }
  wishes.insert(wishes.end(), S_M.begin(), S_M.end());
  wishes.insert(wishes.end(), M_L.begin(), M_L.end());
  wishes.insert(wishes.end(), L_XL.begin(), L_XL.end());
  wishes.insert(wishes.end(), XL_XXL.begin(), XL_XXL.end());
  wishes.insert(wishes.end(), XXL_XXXL.begin(), XXL_XXXL.end());
  for (int i = 0; i < wishes.size(); i++) {
    pair<int, string> wish = wishes[i];
    string sz = wish.second;
    int ind = wish.first;
    int pos = sz.find(",");
    string first = sz.substr(0, pos);
    string second = sz.substr(pos + 1);
    if (sizes[first] == 0 && sizes[second] == 0) {
      cout << "NO";
      return 0;
    }
    if (sizes[first] != 0) {
      results[ind] = first;
      sizes[first]--;
    } else {
      results[ind] = second;
      sizes[second]--;
    }
  }
  cout << "YES" << endl;
  for (int i = 0; i < n; i++) cout << results[i] << endl;
  return 0;
}
