#include <bits/stdc++.h>
using namespace std;
vector<string> seperate(string &s) {
  vector<string> vec;
  int n = s.length();
  string cur;
  for (int i = 0; i < n; ++i) {
    if (s[i] == ',') {
      vec.emplace_back(cur);
      cur = "";
    }
    cur += s[i];
  }
  return vec;
}
int num[6], n, m, c[100000];
vector<string> a[100000];
map<string, int> map1;
map<int, string> map2;
vector<int> to[11];
void body() {
  map1["S"] = 0;
  map1["M"] = 1;
  map1["L"] = 2;
  map1["XL"] = 3;
  map1["XXL"] = 4;
  map1["XXXL"] = 5;
  map2[0] = "S";
  map2[1] = "M";
  map2[2] = "L";
  map2[3] = "XL";
  map2[4] = "XXL";
  map2[5] = "XXXL";
  for (int i = 0; i < 6; ++i) {
    cin >> num[i];
  }
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    s += ",";
    a[i] = seperate(s);
    int v = map1[a[i][0]] * 2;
    to[v + (a[i].size() > 1)].emplace_back(i);
  }
  int cur_size = 0;
  bool okay = 1;
  for (int i = 0; i < 11; ++i) {
    int L = i / 2, R = i / 2 + i % 2;
    for (auto e : to[i]) {
      if (num[L] > 0) {
        c[e] = L;
        --num[L];
      } else {
        if (num[R] > 0) {
          c[e] = R;
          --num[R];
        } else {
          okay = 0;
          break;
        }
      }
    }
  }
  if (!okay) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
    for (int i = 0; i < n; ++i) {
      cout << map2[c[i]] << "\n";
    }
  }
}
void init() { ios::sync_with_stdio(0); }
int main() {
  init();
  body();
}
