#include <bits/stdc++.h>
using namespace std;
vector<int> x;
struct u {
  int a, b, n;
};
int main() {
  long long i, j, l, m, n, k[10] = {0};
  string s;
  u a[200001];
  vector<string> ot;
  for (i = 0; i < 6; i++) cin >> k[i];
  ot.push_back("S");
  ot.push_back("M");
  ot.push_back("L");
  ot.push_back("XL");
  ot.push_back("XXL");
  ot.push_back("XXXL");
  cin >> n;
  getline(cin, s);
  for (i = 0; i < n; i++) {
    a[i].b = -1;
    getline(cin, s);
    string s1;
    j = 0;
    while (j < s.length()) {
      if (s[j] != ',')
        s1 = s1 + s[j];
      else {
        int i1 = 0;
        while (ot[i1] != s1) i1++;
        a[i].b = i1;
        s1 = "";
      }
      j++;
    }
    int i1 = 0;
    while (ot[i1] != s1) i1++;
    a[i].a = i1;
  }
  for (i = 0; i < n; i++) {
    a[i].n = -1;
    if (a[i].b == -1) {
      a[i].n = 1;
      k[a[i].a]--;
    }
  }
  for (i = 5; i >= 0; i--)
    for (j = 0; j < n; j++)
      if (a[j].n == -1) {
        if (a[j].a == i) {
          a[j].n = 1;
          if (k[a[j].a] > 0) {
            k[a[j].a]--;
            a[j].b = -1;
          } else {
            a[j].a = a[j].b;
            a[j].b = -1;
            k[a[j].a]--;
          }
        }
      }
  for (i = 0; i <= 5; i++)
    if (k[i] < 0) {
      cout << "NO";
      return 0;
    }
  cout << "YES" << endl;
  for (i = 0; i < n; i++) cout << ot[a[i].a] << endl;
  return 0;
}
