#include <bits/stdc++.h>
using namespace std;
struct canh {
  int v, c, f;
};
int n, m, k, tmp, s, t;
long long ans;
map<string, int> id;
int sl[11], d[(int)(1e5 + 19)], p[(int)(1e5 + 19)];
string st;
char c[10];
vector<int> ke[(int)(1e5 + 19)];
vector<canh> vc;
char *tostr[] = {"", "S", "M", "L", "XL", "XXL", "XXXL"};
void taomap() {
  id["S"] = n + 1;
  id["M"] = n + 2;
  id["L"] = n + 3;
  id["XL"] = n + 4;
  id["XXL"] = n + 5;
  id["XXXL"] = n + 6;
}
void them(int u, int v, int c) {
  vc.push_back((canh){v, c, 0});
  ke[u].push_back(((int)vc.size() - 1));
  vc.push_back((canh){u, 0, 0});
  ke[v].push_back(((int)vc.size() - 1));
}
void nhap() {
  for (int i = 1; i <= n; i++) {
    while (1) {
      scanf("%[^,\n]", &c);
      int curid = id[c];
      them(i, curid, 1);
      scanf("%c", &c[0]);
      if (c[0] == '\n') break;
    }
    them(0, i, 1);
  }
  t = n + 7;
  for (int i = 1; i <= 6; i++) them(i + n, t, sl[i]);
}
int bfs() {
  memset(d, 0, sizeof d);
  memset(p, 0, sizeof p);
  queue<int> qu;
  qu.push(0);
  d[0] = 1;
  while ((int)qu.size()) {
    int u = qu.front();
    qu.pop();
    if (u == t) return 1;
    for (int i = 0; i <= ((int)ke[u].size() - 1); i++) {
      int id = ke[u][i];
      int v = vc[id].v;
      int c = vc[id].c;
      int f = vc[id].f;
      if (d[v] == 0 && f < c) {
        d[v] = d[u] + 1;
        qu.push(v);
      }
    }
  }
  return 0;
}
void inkq() {
  for (int u = 1; u <= n; u++) {
    for (int i = 0; i <= ((int)ke[u].size() - 1); i++) {
      int id = ke[u][i];
      int v = vc[id].v;
      if (vc[id].f > 0 && n + 1 <= v && v <= n + 6) puts(tostr[v - n]);
    }
  }
}
int dfs(int u, int mi) {
  if (u == t) return mi;
  for (int i = p[u]; i <= ((int)ke[u].size() - 1); i++) {
    int id = ke[u][i];
    int v = vc[id].v;
    int c = vc[id].c;
    int f = vc[id].f;
    if (d[v] == d[u] + 1 && f < c) {
      int gt = dfs(v, min(mi, c - f));
      if (gt > 0) {
        vc[id].f += gt;
        vc[id ^ 1].f -= gt;
        return gt;
      }
    }
    p[u] = i + 1;
  }
  return 0;
}
int main() {
  for (int i = 1; i <= 6; i++) scanf("%d", &sl[i]);
  scanf("%d", &n);
  taomap();
  scanf("\n");
  nhap();
  while (bfs())
    while (int flow = dfs(0, (int)(1e9 + 7))) {
      ans += flow;
    }
  if (ans == n) {
    puts("YES");
    inkq();
  } else
    puts("NO");
  return 0;
}
