#include <bits/stdc++.h>
using namespace std;
namespace MF {
const int N = 500, M = 10000;
int f[N], e[2 * M], c[2 * M], fl[2 * M], nxt[2 * M], ce;
int n, s, t;
int Q[N], lvl[N];
int le[N];
void init(int _n) {
  n = _n + 2, s = _n, t = _n + 1;
  ce = 0;
  for (int i = (0); i < (n); i++) f[i] = -1;
}
int add(int a, int b, int cap) {
  nxt[ce] = f[a];
  f[a] = ce;
  e[ce] = b;
  fl[ce] = 0;
  c[ce] = cap;
  ce++;
  nxt[ce] = f[b];
  f[b] = ce;
  e[ce] = a;
  fl[ce] = 0;
  c[ce] = 0;
  ce++;
  return ce - 2;
}
bool bfs() {
  for (int i = (0); i < (n); i++) lvl[i] = -1;
  int qi = 1;
  Q[0] = s;
  lvl[s] = 0;
  for (int i = (0); i < (qi); i++) {
    int x = Q[i];
    le[x] = f[x];
    for (int j = f[x]; j >= 0; j = nxt[j])
      if (c[j] - fl[j] > 0) {
        int y = e[j];
        if (lvl[y] == -1) {
          lvl[y] = lvl[x] + 1;
          Q[qi++] = y;
        }
      }
  }
  return lvl[t] != -1;
}
int aug(int cu, int cf) {
  if (cu == t) return cf;
  for (int &i = le[cu]; i >= 0; i = nxt[i])
    if (c[i] - fl[i] > 0) {
      int x = e[i];
      if (lvl[x] != lvl[cu] + 1) continue;
      int rf = aug(x, min(cf, c[i] - fl[i]));
      if (rf > 0) {
        fl[i] += rf;
        fl[i ^ 1] -= rf;
        assert(fl[i] == -fl[i ^ 1]);
        return rf;
      }
    }
  lvl[cu] = -1;
  return 0;
}
int mf() {
  int tot = 0;
  while (bfs())
    for (int x = aug(s, 1e9); x; x = aug(s, 1e9)) tot += x;
  return tot;
}
}  // namespace MF
string lst[] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int N, occ[6], sz[50], ans[100100];
vector<int> adj[50];
vector<int> id[50];
char buf[50];
pair<int, int> shit[50];
int main() {
  for (int i = (0); i < (6); i++) scanf("%d", &occ[i]);
  scanf("%d", &N);
  for (int i = (0); i < (N); i++) {
    scanf(" %s", buf);
    string in(buf), a, b;
    bool passed = 0;
    for (int j = (0); j < ((int)in.size()); j++) {
      if (in[j] == ',')
        passed = 1;
      else {
        if (passed)
          b += in[j];
        else
          a += in[j];
      }
    }
    int x = -1, y = -1;
    for (int j = (0); j < (6); j++)
      if (a == lst[j]) x = j;
    for (int j = (0); j < (6); j++)
      if (b == lst[j]) y = j;
    if (y == -1) y = x;
    if (y < x) swap(x, y);
    sz[x * 6 + y]++;
    id[x * 6 + y].push_back(i);
  }
  MF::init(50);
  for (int i = (0); i < (6); i++)
    for (int j = (i); j < (6); j++) {
      int x = i * 6 + j;
      MF::add(MF::s, x, sz[x]);
      if (i == j) {
        shit[x].first = MF::add(x, 36 + i, sz[x]);
      } else {
        shit[x].first = MF::add(x, 36 + i, sz[x]);
        shit[x].second = MF::add(x, 36 + j, sz[x]);
      }
    }
  for (int i = (36); i < (36 + 6); i++) {
    MF::add(i, MF::t, occ[i - 36]);
  }
  int res = MF::mf();
  if (res == N) {
    puts("YES");
    for (int i = (0); i < (6); i++)
      for (int j = (i); j < (6); j++) {
        int x = i * 6 + j;
        if (i == j) {
          for (int v : id[x]) ans[v] = i;
        } else {
          assert(MF::fl[shit[x].first] + MF::fl[shit[x].second] == sz[x]);
          for (int rep = (0); rep < (MF::fl[shit[x].first]); rep++)
            ans[id[x].back()] = i, id[x].pop_back();
          for (int v : id[x]) ans[v] = j;
        }
      }
    for (int i = (0); i < (N); i++) printf("%s\n", lst[ans[i]].c_str());
  } else
    puts("NO");
  return 0;
}
