#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  map<string, int> kek;
  map<int, string> wtf;
  kek["S"] = 0;
  kek["M"] = 1;
  kek["L"] = 2;
  kek["XL"] = 3;
  kek["XXL"] = 4;
  kek["XXXL"] = 5;
  wtf[0] = "S";
  wtf[1] = "M";
  wtf[2] = "L";
  wtf[3] = "XL";
  wtf[4] = "XXL";
  wtf[5] = "XXXL";
  vector<int> kol(6);
  for (int i = 0; i < 6; ++i) {
    cin >> kol[i];
  }
  int m;
  cin >> m;
  vector<vector<int> > ans(6);
  vector<string> answer(m);
  vector<bool> used(m, 0);
  vector<string> vv;
  string s;
  vector<string> vod(2);
  int x;
  for (int i = 0; i < m; ++i) {
    cin >> s;
    vod[0] = "", vod[1] = "";
    x = 0;
    for (int j = 0; j < s.length(); ++j) {
      if (s[j] != ',') {
        vod[x] += s[j];
      } else {
        x++;
      }
    }
    if (x == 0) {
      kol[kek[vod[0]]]--;
      answer[i] = vod[0];
      used[i] = 1;
    } else {
      if (kol[kek[vod[0]]] <= 0) {
        kol[kek[vod[1]]]--;
        answer[i] = vod[1];
        used[i] = 1;
      } else if (kol[kek[vod[1]]] <= 0) {
        kol[kek[vod[0]]]--;
        answer[i] = vod[0];
        used[i] = 1;
      } else {
        ans[kek[vod[0]]].push_back(i);
        ans[kek[vod[1]]].push_back(i);
      }
    }
  }
  for (int i = 0; i < 6; ++i) {
    if (kol[i] < 0) {
      cout << "NO";
      return 0;
    }
  }
  int i = 0;
  while (i < 6) {
    while ((!ans[i].empty()) && kol[i] > 0) {
      if (!used[ans[i][ans[i].size() - 1]]) {
        kol[i]--;
        answer[ans[i][ans[i].size() - 1]] = wtf[i];
        used[ans[i][ans[i].size() - 1]] = 1;
      }
      ans[i].pop_back();
    }
    i++;
    while (i < 6 && (!ans[i - 1].empty()) && kol[i] > 0) {
      if (!used[ans[i - 1][ans[i - 1].size() - 1]]) {
        kol[i]--;
        answer[ans[i - 1][ans[i - 1].size() - 1]] = wtf[i];
        used[ans[i - 1][ans[i - 1].size() - 1]] = 1;
      }
      ans[i - 1].pop_back();
    }
  }
  for (int i = 0; i < m; ++i) {
    if (!used[i]) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES\n";
  for (int i = 0; i < m; ++i) {
    cout << answer[i] << '\n';
  }
  return 0;
}
