#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
const int maxm = 1005;
const int inf = INT_MAX;
int n;
int r[10];
struct N {
  int s;
  bool c;
  int no;
  int ans;
  bool operator<(const N &b) const {
    if (this->s < b.s) return true;
    if (this->s == b.s) {
      if (this->c != b.c)
        return !this->c;
      else
        return this->no < b.no;
    }
    return false;
  }
};
bool comp(const N &a, const N &b) { return a.no < b.no; }
N a[maxn];
int ans[maxn];
int main() {
  for (int i = 1; i <= 6; i++) scanf("%d", &r[i]);
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    char str[10];
    scanf("%s", str);
    int l;
    l = strlen(str);
    if (l == 8) {
      a[i].s = 5;
      a[i].c = true;
    } else if (l == 6) {
      a[i].s = 4;
      a[i].c = true;
    } else if (l == 4) {
      if (str[1] == ',') {
        a[i].s = 3;
        a[i].c = true;
      } else {
        a[i].s = 6;
        a[i].c = false;
      }
    } else if (l == 3) {
      if (str[0] == 'X') {
        a[i].s = 5;
        a[i].c = false;
      } else {
        if (str[0] == 'S') a[i].s = 1;
        if (str[0] == 'M') a[i].s = 2;
        a[i].c = true;
      }
    } else if (l == 2) {
      a[i].s = 4;
      a[i].c = false;
    } else {
      if (str[0] == 'S')
        a[i].s = 1;
      else if (str[0] == 'M')
        a[i].s = 2;
      else
        a[i].s = 3;
      a[i].c = false;
    }
    a[i].no = i;
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) {
    if (r[a[i].s] <= 0) {
      if (a[i].c) {
        if (r[a[i].s + 1] <= 0) {
          printf("NO\n");
          return 0;
        } else {
          r[a[i].s + 1]--;
          a[i].ans = a[i].s + 1;
        }
      } else {
        printf("NO\n");
        return 0;
      }
    } else {
      r[a[i].s]--;
      a[i].ans = a[i].s;
    }
  }
  sort(a, a + n, comp);
  printf("YES\n");
  for (int i = 0; i < n; i++) {
    if (a[i].ans == 1) printf("S\n");
    if (a[i].ans == 2) printf("M\n");
    if (a[i].ans == 3) printf("L\n");
    if (a[i].ans == 4) printf("XL\n");
    if (a[i].ans == 5) printf("XXL\n");
    if (a[i].ans == 6) printf("XXXL\n");
  }
  return 0;
}
