#include <bits/stdc++.h>
using namespace std;
int num[8], p[100005];
struct node {
  int x, t;
} a[100005];
char names[6][6] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int ff(char *s) {
  if (s[0] == 'S') return 0;
  if (s[0] == 'M') return 1;
  if (s[0] == 'L') return 2;
  if (s[1] == 'L') return 3;
  if (s[2] == 'L') return 4;
  if (s[3] == 'L') return 5;
}
bool cmp(node a, node b) { return b.x > a.x; }
int slove(int cnt) {
  sort(a, a + cnt, cmp);
  for (int i = 0; i < cnt; i++) {
    if (num[a[i].x]) {
      num[a[i].x]--;
      p[a[i].t] = a[i].x;
    } else if (num[a[i].x + 1]) {
      num[a[i].x + 1]--;
      p[a[i].t] = a[i].x + 1;
    } else
      return 0;
  }
  return 1;
}
int main() {
  int sum = 0, n;
  char name[7][11];
  for (int i = 0; i < 6; i++) {
    scanf("%d", &num[i]);
    sum += num[i];
  }
  scanf("%d", &n);
  int cnt = 0;
  char str[11], str1[11], str2[11];
  for (int i = 0; i < n; i++) {
    scanf("%s", str);
    int j, k;
    for (j = 0; str[j] != ',' && str[j]; j++) str1[j] = str[j];
    str1[j] = '\0';
    if (j == strlen(str)) {
      int ss = ff(str1);
      p[i] = ss;
      num[ss]--;
    } else {
      for (k = j + 1; str[k]; k++) str2[k - j - 1] = str[k];
      str2[k - j - 1] = '\0';
      a[cnt].x = min(ff(str1), ff(str2));
      a[cnt++].t = i;
    }
  }
  if (sum < n) {
    printf("NO\n");
    return 0;
  }
  int gg = slove(cnt);
  for (int i = 0; i < 6; i++)
    if (num[i] < 0) gg = 0;
  if (!gg)
    printf("NO\n");
  else {
    printf("YES\n");
    for (int i = 0; i < n; i++) printf("%s\n", names[p[i]]);
  }
}
