#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
const int inf = 0x7f7f7f7f;
const int MOD = 1000000007;
map<string, int> m;
string mm[6] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int num[8];
int ans[100007];
struct node {
  int s1, s2, id;
  bool operator<(const node& p) const {
    if (s1 == p.s1) return s2 > p.s2;
    return s1 < p.s1;
  }
} nod[100007];
int main() {
  string s, tp;
  m["S"] = 0;
  m["M"] = 1;
  m["L"] = 2;
  m["XL"] = 3;
  m["XXL"] = 4;
  m["XXXL"] = 5;
  for (int i = 0; i < 6; i++) scanf("%d", num + i);
  int n;
  scanf("%d", &n);
  int f = 0;
  for (int j = 0; j < n; j++) {
    s = tp = "";
    nod[j].s2 = 99;
    nod[j].id = j;
    cin >> s;
    f = 0;
    int l = s.length();
    for (int i = 0; i < l; i++) {
      if (s[i] != ',')
        tp += s[i];
      else {
        nod[j].s1 = m[tp];
        tp = "";
        f = 1;
      }
    }
    tp += "";
    if (f) {
      nod[j].s2 = m[tp];
      if (nod[j].s1 > nod[j].s2) swap(nod[j].s1, nod[j].s2);
    } else
      nod[j].s1 = m[tp];
  }
  f = 0;
  sort(nod, nod + n);
  for (int i = 0; i < n; i++) {
    int s1 = nod[i].s1;
    int s2 = nod[i].s2;
    if (num[s1]) {
      num[s1]--;
      ans[nod[i].id] = s1;
    } else if (s2 < 6) {
      if (num[s2]) {
        num[s2]--;
        ans[nod[i].id] = s2;
      } else {
        f = 1;
        break;
      }
    } else {
      f = 1;
      break;
    }
  }
  if (f)
    printf("NO\n");
  else {
    printf("YES\n");
    for (int i = 0; i < n; i++) {
      cout << mm[ans[i]] << endl;
    }
  }
}
