#include <bits/stdc++.h>
using namespace std;
const int maxL = 70;
int mod = 1e9 + 7;
long long mod1 = 1e9 + 7;
const int inf = 1.2e18;
const int maxn = 6e5 + 100;
const int baze = 330;
const int base = 3;
int from[maxn];
int to[maxn];
int w[maxn];
int dis[maxn];
int head[maxn];
int sdfgf[maxn];
int backup[maxn];
int chiz[maxn];
int eof, source = maxn - 1, sink = maxn - 2;
void add_edge(int u, int v, int W) {
  from[eof] = u, to[eof] = v, w[eof] = W, sdfgf[eof] = head[u], head[u] = eof++;
  swap(u, v);
  W = 0;
  from[eof] = u, to[eof] = v, w[eof] = W, sdfgf[eof] = head[u], head[u] = eof++;
}
bool bfs() {
  int st = 0, en = 1;
  chiz[0] = source;
  memset(dis, 63, sizeof dis);
  dis[source] = 0;
  while (st < en) {
    int v = chiz[st++];
    for (int e = head[v]; ~e; e = sdfgf[e])
      if (w[e] && dis[to[e]] > dis[v] + 1) {
        dis[to[e]] = dis[v] + 1;
        chiz[en++] = to[e];
        if (to[e] == sink) return true;
      }
  }
  return false;
}
int dfs(int v, int mn = 1000000) {
  if (!mn || v == sink) return mn;
  int ret = 0;
  for (int &e = head[v]; ~e; e = sdfgf[e])
    if (dis[to[e]] == dis[v] + 1) {
      int x = dfs(to[e], min(mn, w[e]));
      ret += x;
      w[e] -= x;
      w[e ^ 1] += x;
      mn -= x;
      if (mn == 0) break;
    }
  return ret;
}
int flow() {
  memcpy(backup, head, sizeof head);
  int ret = 0;
  while (bfs()) {
    ret += dfs(source);
    memcpy(head, backup, sizeof head);
  }
  return ret;
}
int ar[60];
string t[maxn];
int pos[maxn];
int n;
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  memset(head, -1, sizeof head);
  map<string, int> mp;
  mp["S"] = 0;
  mp["M"] = 1;
  mp["L"] = 2;
  mp["XL"] = 3;
  mp["XXL"] = 4;
  mp["XXXL"] = 5;
  for (int i = 0; i < 6; i++) cin >> ar[i], add_edge(source, i, ar[i]);
  cin >> n;
  vector<int> vc;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    t[i] = s;
    pos[i] = ((int)((s).size()));
    if (s.find(',') < ((int)((s).size()))) {
      int x = s.find(',');
      pos[i] = x;
      vc.push_back(eof);
      add_edge(mp[s.substr(0, x)], i + 10, 1);
      add_edge(mp[s.substr(x + 1, ((int)((s).size())))], i + 10, 1);
      add_edge(i + 10, sink, 1);
    } else
      vc.push_back(eof), add_edge(mp[s], sink, 1);
  }
  int ans = flow();
  if (ans != n) return cout << "NO" << endl, 0;
  cout << "YES" << endl;
  int hlp = 0;
  for (int x : vc) {
    if (w[x] == 0)
      cout << t[hlp].substr(0, pos[hlp]) << '\n';
    else
      cout << t[hlp].substr(pos[hlp] + 1, ((int)((t[hlp]).size()))) << '\n';
    hlp++;
  }
}
