#include <bits/stdc++.h>
char ss[][10] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int ind(char *t) {
  int i;
  for (i = 0; i < 6; i++)
    if (strncmp(t, ss[i], strlen(ss[i])) == 0) break;
  return i;
}
struct tshirt {
  int i, j;
} tt[100000];
int compare(const void *a, const void *b) {
  struct tshirt *pa = (struct tshirt *)a;
  struct tshirt *pb = (struct tshirt *)b;
  return pa->i - pb->i;
}
int main() {
  int i, k, n, yes;
  static char s[10], t[100000][10];
  static int cnt[6];
  for (i = 0; i < 6; i++) scanf("%d", &cnt[i]);
  scanf("%d", &n);
  yes = 1;
  k = 0;
  for (i = 0; i < n; i++) {
    int j, l, two;
    scanf("%s", s);
    l = strlen(s);
    two = 0;
    for (j = 0; j < l; j++)
      if (s[j] == ',') {
        two = 1;
        break;
      }
    if (!two) {
      j = ind(s);
      if (cnt[j] == 0) {
        yes = 0;
        break;
      }
      strcpy(t[i], s);
      cnt[j]--;
    } else {
      tt[k].i = ind(s);
      tt[k++].j = i;
    }
  }
  if (yes) {
    int i;
    qsort(tt, k, sizeof(*tt), compare);
    for (i = 0; i < k; i++)
      if (cnt[tt[i].i] > 0) {
        cnt[tt[i].i]--;
        strcpy(t[tt[i].j], ss[tt[i].i]);
      } else if (tt[i].i + 1 < 6 && cnt[tt[i].i + 1] > 0) {
        cnt[tt[i].i + 1]--;
        strcpy(t[tt[i].j], ss[tt[i].i + 1]);
      } else {
        yes = 0;
        break;
      }
  }
  printf("%s\n", yes ? "YES" : "NO");
  if (yes)
    for (i = 0; i < n; i++) printf("%s\n", t[i]);
  return 0;
}
