#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
struct Dinic {
  static const int MAXN = 100015;
  struct Edge {
    int u, v;
    long long cap, rest;
  };
  int n, m, s, t, d[MAXN], cur[MAXN];
  vector<Edge> edges;
  vector<int> G[MAXN];
  int chosen[MAXN];
  void init() {
    memset(chosen, 0, sizeof(chosen));
    edges.clear();
    for (int i = 0; i < MAXN; i++) G[i].clear();
  }
  void add_edge(int u, int v, long long cap) {
    edges.push_back({u, v, cap, cap});
    edges.push_back({v, u, 0, 0LL});
    m = edges.size();
    G[u].push_back(m - 2);
    G[v].push_back(m - 1);
  }
  bool bfs() {
    memset(d, -1, sizeof(d));
    queue<int> que;
    que.push(s);
    d[s] = 0;
    while (!que.empty()) {
      int u = que.front();
      que.pop();
      for (int ei : G[u]) {
        Edge &e = edges[ei];
        if (d[e.v] < 0 && e.rest > 0) {
          d[e.v] = d[u] + 1;
          que.push(e.v);
        }
      }
    }
    return d[t] >= 0;
  }
  long long dfs(int u, long long a) {
    if (u == t || a == 0) return a;
    long long flow = 0, f;
    for (int &i = cur[u]; i < (int)G[u].size(); i++) {
      Edge &e = edges[G[u][i]];
      if (d[u] + 1 != d[e.v]) continue;
      f = dfs(e.v, min(a, e.rest));
      if (f > 0) {
        if (u <= 6 && u >= 1) {
          chosen[e.v] = u;
        }
        e.rest -= f;
        edges[G[u][i] ^ 1].rest += f;
        flow += f;
        a -= f;
        if (a == 0) break;
      }
    }
    return flow;
  }
  long long maxflow(int s, int t) {
    this->s = s, this->t = t;
    long long flow = 0, mf;
    while (bfs()) {
      memset(cur, 0, sizeof(cur));
      while ((mf = dfs(s, INF))) flow += mf;
    }
    return flow;
  }
} dinic;
int main(void) {
  ios_base::sync_with_stdio(false);
  long long int tshirt[7];
  while (cin >> tshirt[1]) {
    for (int i = 2; i <= 6; i++) {
      cin >> tshirt[i];
    }
    dinic.init();
    for (int i = 1; i <= 6; i++) {
      dinic.add_edge(0, i, tshirt[i]);
    }
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      string sz;
      cin >> sz;
      string temp;
      for (auto j : sz) {
        if (j != ',') {
          temp.push_back(j);
        } else {
          int type;
          if (temp == "S") {
            type = 1;
          }
          if (temp == "M") {
            type = 2;
          }
          if (temp == "L") {
            type = 3;
          }
          if (temp == "XL") {
            type = 4;
          }
          if (temp == "XXL") {
            type = 5;
          }
          if (temp == "XXXL") {
            type = 6;
          }
          dinic.add_edge(type, i + 6, 1);
          temp.clear();
        }
      }
      int type;
      if (temp == "S") {
        type = 1;
      }
      if (temp == "M") {
        type = 2;
      }
      if (temp == "L") {
        type = 3;
      }
      if (temp == "XL") {
        type = 4;
      }
      if (temp == "XXL") {
        type = 5;
      }
      if (temp == "XXXL") {
        type = 6;
      }
      dinic.add_edge(type, i + 6, 1);
      temp.clear();
      dinic.add_edge(i + 6, 6 + n + 1, 1);
    }
    long long int total = dinic.maxflow(0, 6 + n + 1);
    if (total < n) {
      cout << "NO\n";
    } else {
      cout << "YES\n";
      for (int i = 1; i <= n; i++) {
        int type = dinic.chosen[i + 6];
        if (type == 1) {
          cout << "S\n";
        }
        if (type == 2) {
          cout << "M\n";
        }
        if (type == 3) {
          cout << "L\n";
        }
        if (type == 4) {
          cout << "XL\n";
        }
        if (type == 5) {
          cout << "XXL\n";
        }
        if (type == 6) {
          cout << "XXXL\n";
        }
      }
    }
  }
}
