#include <bits/stdc++.h>
using namespace std;
int num[7];
char str[10];
char size[7][10] = {"1", "S", "M", "L", "XL", "XXL", "XXXL"};
int find(int st, int len) {
  char s[10];
  strncpy(s, str + st, len);
  s[len] = 0;
  if (strcmp(s, "S") == 0) return 1;
  if (strcmp(s, "M") == 0) return 2;
  if (strcmp(s, "L") == 0) return 3;
  if (strcmp(s, "XL") == 0) return 4;
  if (strcmp(s, "XXL") == 0) return 5;
  if (strcmp(s, "XXXL") == 0) return 6;
}
struct Segment {
  int x, y;
  int id;
  Segment() {}
  Segment(int _x, int _y, int _id) {
    x = _x;
    y = _y;
    id = _id;
  }
  friend bool operator<(const Segment &a, const Segment &b) {
    return a.x < b.x;
  }
} l[100100];
int cnt = 0, n;
char ans[100100][10];
int main() {
  for (int i = 1; i <= 6; i++) {
    scanf("%d", &num[i]);
  }
  scanf("%d", &n);
  cnt = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%s", str);
    int len = strlen(str);
    int pos = 0;
    for (int j = 0; j < len; j++) {
      if (str[j] == ',') {
        pos = j;
        break;
      }
    }
    if (pos)
      l[++cnt] = Segment(find(0, pos), find(pos + 1, len - pos - 1), i);
    else {
      int x = find(0, len);
      if (num[x]) {
        strcpy(ans[i], str);
        num[x]--;
      } else {
        puts("NO");
        return 0;
      }
    }
  }
  sort(l + 1, l + cnt + 1);
  for (int i = 1; i <= cnt; i++) {
    if (num[l[i].x]) {
      num[l[i].x]--;
      strcpy(ans[l[i].id], size[l[i].x]);
    } else if (num[l[i].y]) {
      num[l[i].y]--;
      strcpy(ans[l[i].id], size[l[i].y]);
    } else {
      puts("NO");
      return 0;
    }
  }
  puts("YES");
  for (int i = 1; i <= n; i++) {
    puts(ans[i]);
  }
  return 0;
}
