#include <bits/stdc++.h>
using namespace std;
bool check[200006];
long long sz[200006];
int main() {
  long long frq[7];
  map<string, long long> mp;
  vector<long long> keep[7];
  string str[7];
  str[1] = "S";
  str[2] = "M";
  str[3] = "L";
  str[4] = "XL";
  str[5] = "XXL";
  str[6] = "XXXL";
  mp["S"] = 1;
  mp["M"] = 2;
  mp["L"] = 3;
  mp["XL"] = 4;
  mp["XXL"] = 5;
  mp["XXXL"] = 6;
  for (long long i = 1; i <= 6; i++) scanf("%lld", &frq[i]);
  long long n;
  cin >> n;
  bool no = false;
  for (long long i = 1; i <= n; i++) {
    string A;
    cin >> A;
    bool ys = false;
    string B = "", C = "";
    for (long long j = 0; j < A.size(); j++) {
      if (A[j] == ',') {
        ys = true;
        continue;
      }
      if (!ys)
        B += A[j];
      else
        C += A[j];
    }
    if (!ys) {
      if (frq[mp[A]] == 0) no = true;
      frq[mp[A]]--;
      sz[i] = mp[A];
      continue;
    }
    keep[mp[B]].push_back(i);
    keep[mp[C]].push_back(i);
  }
  stack<long long> st;
  for (long long i = 1; i <= 6; i++) {
    while (!st.empty()) {
      if (frq[i] == 0) {
        no = true;
        break;
      }
      check[st.top()] = true;
      sz[st.top()] = i;
      frq[i]--;
      st.pop();
    }
    if (no) break;
    for (long long j = 0; j < keep[i].size(); j++) {
      if (check[keep[i][j]]) continue;
      if (frq[i]) {
        check[keep[i][j]] = true;
        sz[keep[i][j]] = i;
        frq[i]--;
        continue;
      }
      st.push(keep[i][j]);
    }
  }
  if (no)
    puts("NO");
  else {
    puts("YES");
    for (long long i = 1; i <= n; i++) cout << str[sz[i]] << endl;
  }
}
