#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pli = pair<ll, int>;
const int INF = 0x3f3f3f3f;
const ll LINF = 1e18 + 5;
const int N = 2e5 + 105, M = 1e6 + 5;
int n;
int cnt, head[N], a[6];
map<string, int> id;
map<int, string> rid;
struct node {
  int next, to, w;
} e[M << 1];
inline void add(int u, int v, int w) {
  e[++cnt].next = head[u];
  e[cnt].to = v;
  e[cnt].w = w;
  head[u] = cnt;
}
struct Dinic {
  int n, m, s, t;
  int dep[N], cur[N];
  void init(int n, int s, int t) {
    this->s = s, this->t = t, this->n = n;
    cnt = 1, m = 0;
    memset(head, 0, (n + 1) * sizeof(int));
  }
  void addedge(int u, int v, int cap) {
    add(u, v, cap);
    add(v, u, 0);
    m += 2;
  }
  bool bfs() {
    memset(dep, 0, (n + 1) * sizeof(int));
    memcpy(cur, head, (n + 1) * sizeof(int));
    queue<int> q;
    q.push(s);
    dep[s] = 1;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (int i = head[u]; i; i = e[i].next) {
        int v = e[i].to;
        if (!dep[v] && e[i].w > 0) {
          dep[v] = dep[u] + 1;
          q.push(v);
        }
      }
    }
    return dep[t];
  }
  int dfs(int u, int flow) {
    if (u == t || !flow) return flow;
    int used = flow;
    for (int i = cur[u]; i; i = e[i].next) {
      cur[u] = i;
      int v = e[i].to;
      if (dep[v] == dep[u] + 1) {
        int low = dfs(v, min(flow, e[i].w));
        e[i].w -= low;
        e[i ^ 1].w += low;
        flow -= low;
        if (!flow) break;
      }
    }
    return used - flow;
  }
  int go() {
    int maxflow = 0;
    while (bfs()) maxflow += dfs(s, INF);
    return maxflow;
  }
} MF;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  id["S"] = 0;
  id["M"] = 1;
  id["L"] = 2;
  id["XL"] = 3;
  id["XXL"] = 4;
  id["XXXL"] = 5;
  rid[0] = "S";
  rid[1] = "M";
  rid[2] = "L";
  rid[3] = "XL";
  rid[4] = "XXL";
  rid[5] = "XXXL";
  for (int i = 0; i <= 5; i++) cin >> a[i];
  cin >> n;
  MF.init(2 * n + 8, 0, 2 * n + 7);
  for (int i = 0; i <= 5; i++) MF.addedge(2 * n + i + 1, MF.t, a[i]);
  for (int i = 1; i <= n; i++) {
    string s, x, y;
    cin >> s;
    bool tag = 0;
    MF.addedge(2 * i - 1, 2 * i, 1);
    MF.addedge(MF.s, 2 * i - 1, INF);
    for (int j = 0; j < (int)s.size(); j++) {
      if (s[j] == ',') {
        tag = 1;
        x = s.substr(0, j);
        y = s.substr(j + 1);
        MF.addedge(2 * i, 2 * n + id[x] + 1, 1);
        MF.addedge(2 * i, 2 * n + id[y] + 1, 1);
        break;
      }
    }
    if (!tag) MF.addedge(2 * i, 2 * n + id[s] + 1, 1);
  }
  int res = MF.go();
  if (res != n) return cout << "NO", 0;
  cout << "YES" << '\n';
  for (int u = 1; u <= n; u++) {
    for (int i = head[2 * u]; i; i = e[i].next) {
      int v = e[i].to, w = e[i].w;
      if (v - 2 * n - 1 < 0) continue;
      if (!w) cout << rid[v - 2 * n - 1] << '\n';
    }
  }
  return 0;
}
