#include <bits/stdc++.h>
using namespace std;
map<string, int> f;
struct pii {
  int first, second, id;
};
pii a[111111];
bool cmp(pii t1, pii t2) {
  if (t1.first != t2.first)
    return t1.first < t2.first;
  else
    return t1.second < t2.second;
}
int b[11];
char s[55];
char s1[11], s2[11];
int c[111111];
char ff[11][7] = {"", "S", "M", "L", "XL", "XXL", "XXXL"};
int main() {
  f["S"] = 1, f["M"] = 2, f["L"] = 3;
  f["XL"] = 4, f["XXL"] = 5, f["XXXL"] = 6;
  int i, j, n, len, k;
  int p1, p2;
  for (i = 1; i <= 6; i++) scanf("%d", &b[i]);
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%s", s);
    len = strlen(s);
    for (j = 0; j < len; j++)
      if (s[j] == ',') break;
    if (j == len) {
      a[i].first = 0;
      a[i].second = f[s];
      a[i].id = i;
    } else {
      for (j = 0;; j++) {
        if (s[j] == ',') break;
        s1[j] = s[j];
      }
      k = j + 1;
      s1[j] = '\0';
      for (; k < len; k++) {
        s2[k - j - 1] = s[k];
      }
      s2[k - j - 1] = '\0';
      p1 = f[s1];
      p2 = f[s2];
      if (p1 > p2) swap(p1, p2);
      a[i].first = 1;
      a[i].second = p1;
      a[i].id = i;
    }
  }
  sort(a + 1, a + 1 + n, cmp);
  for (i = 1; i <= n; i++) {
    if (a[i].first) {
      p1 = a[i].second;
      p2 = p1 + 1;
      if (b[p1] <= 0 && b[p2] <= 0) break;
      if (b[p1] > 0) {
        b[p1]--;
        c[a[i].id] = p1;
      } else {
        b[p2]--;
        c[a[i].id] = p2;
      }
    } else {
      p1 = a[i].second;
      if (b[p1] > 0) {
        b[p1]--;
        c[a[i].id] = p1;
      } else
        break;
    }
  }
  if (i > n) {
    printf("YES\n");
    for (i = 1; i <= n; i++) printf("%s\n", ff[c[i]]);
  } else
    printf("NO\n");
  return 0;
}
