#include <bits/stdc++.h>
using namespace std;
int n, ts[7];
vector<int> dts[7];
string ans[100001], want;
bool can = true;
string conv(int x) {
  if (x == 0) return ("S");
  if (x == 1) return ("M");
  if (x == 2) return ("L");
  if (x == 3) return ("XL");
  if (x == 4) return ("XXL");
  if (x == 5) return ("XXXL");
}
int main() {
  for (int i = 0; i < 6; ++i) cin >> ts[i];
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> want;
    int len = want.length();
    string pref = "";
    bool g = false;
    for (int j = 0; j < len; ++j) {
      if (want[j] == ',') {
        g = true;
        if (pref == "S") dts[0].push_back(i);
        if (pref == "M") dts[1].push_back(i);
        if (pref == "L") dts[2].push_back(i);
        if (pref == "XL") dts[3].push_back(i);
        if (pref == "XXL") dts[4].push_back(i);
        if (pref == "XXXL") dts[5].push_back(i);
      }
      pref = pref + want[j];
    }
    if (g == false) {
      if (pref == "S") {
        ans[i] = "S";
        ts[0]--;
        if (ts[0] < 0) can = false;
      }
      if (pref == "M") {
        ans[i] = "M";
        ts[1]--;
        if (ts[1] < 0) can = false;
      }
      if (pref == "L") {
        ans[i] = "L";
        ts[2]--;
        if (ts[2] < 0) can = false;
      }
      if (pref == "XL") {
        ans[i] = "XL";
        ts[3]--;
        if (ts[3] < 0) can = false;
      }
      if (pref == "XXL") {
        ans[i] = "XXL";
        ts[4]--;
        if (ts[4] < 0) can = false;
      }
      if (pref == "XXXL") {
        ans[i] = "XXXL";
        ts[5]--;
        if (ts[5] < 0) can = false;
      }
    }
  }
  for (int i = 0; i < 5; ++i) {
    if (can == false) break;
    for (auto it = 0; it < dts[i].size(); ++it) {
      if (ts[i] > 0) {
        ans[dts[i][it]] = conv(i);
        ts[i]--;
      } else {
        if (ts[i + 1] <= 0) {
          can = false;
          break;
        } else {
          ans[dts[i][it]] = conv(i + 1);
          ts[i + 1]--;
        }
      }
    }
  }
  if (can == true) {
    cout << "YES" << endl;
    for (int i = 0; i < n; ++i) cout << ans[i] << endl;
  } else
    cout << "NO";
  return (0);
}
