#include <bits/stdc++.h>
using namespace std;
class edge {
 public:
  long long int u, v, flow, cap;
  edge(long long int u, long long int v, long long int cap)
      : u(u), v(v), cap(cap), flow(0) {}
};
class dinic {
 public:
  vector<edge> ed;
  vector<vector<long long int>> adj;
  vector<long long int> lvl, ptr;
  queue<long long int> q;
  long long int s, t, n, m = 0, inf = 1e18;
  dinic(long long int n, long long int s, long long int t) : s(s), t(t), n(n) {
    lvl.resize(n, 0);
    ptr.resize(n, 0);
    adj.resize(n);
  }
  void add_edge(long long int u, long long int v, long long int cap) {
    ed.emplace_back(u, v, cap);
    ed.emplace_back(v, u, 0);
    adj[u].push_back(m);
    adj[v].push_back(m + 1);
    m += 2;
  }
  bool bfs() {
    while (!q.empty()) {
      long long int u = q.front();
      q.pop();
      for (auto x : adj[u]) {
        long long int v = ed[x].v;
        if (lvl[v] == -1 && ed[x].cap - ed[x].flow > 0)
          lvl[v] = lvl[u] + 1, q.push(v);
      }
    }
    return lvl[t] != -1;
  }
  long long int dfs(long long int u, long long int flow) {
    if (!flow) return 0;
    if (u == t) return flow;
    for (long long int &id = ptr[u]; id < adj[u].size(); id++) {
      long long int x = adj[u][id];
      long long int v = ed[x].v;
      if (lvl[v] == lvl[u] + 1 && ed[x].cap - ed[x].flow > 0) {
        long long int temp = dfs(v, min(flow, ed[x].cap - ed[x].flow));
        if (temp) {
          ed[x].flow += temp;
          ed[x ^ 1].flow -= temp;
          return temp;
        }
      }
    }
    return 0;
  }
  long long int maxflow() {
    long long int mf = 0;
    while (1) {
      fill(lvl.begin(), lvl.end(), -1);
      lvl[s] = 0, q.push(s);
      if (!bfs()) break;
      fill(ptr.begin(), ptr.end(), 0);
      while (long long int f = dfs(s, inf)) mf += f;
    }
    return mf;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int T = 1;
  for (long long int qq = 1; qq <= T; qq++) {
    long long int k[6];
    for (int i = 0; i < 6; i++) {
      cin >> k[i];
    }
    long long int n;
    cin >> n;
    dinic fl(n + 8, 0, n + 7);
    for (int i = 0; i < 6; i++) fl.add_edge(0, i + 1, k[i]);
    map<string, long long int> mp;
    mp["S"] = 1, mp["M"] = 2, mp["L"] = 3, mp["XL"] = 4, mp["XXL"] = 5,
    mp["XXXL"] = 6;
    string v[] = {"r", "S", "M", "L", "XL", "XXL", "XXXL"};
    for (int i = 0; i < n; i++) {
      string s;
      cin >> s;
      long long int x = 0, y = 0;
      while (x != s.size() && s[x] != ',') x++;
      if (x != s.size()) y = 1;
      x = mp[s.substr(0, x)];
      if (y) fl.add_edge(x + 1, i + 7, 1);
      fl.add_edge(x, i + 7, 1);
      fl.add_edge(i + 7, n + 7, 1);
    }
    if (fl.maxflow() == n) {
      cout << "YES" << endl;
      vector<long long int> ans(n);
      for (auto x : fl.ed) {
        if (x.u >= 1 && x.u <= 6 && x.flow > 0 && x.v > 0) ans[x.v - 7] = x.u;
      }
      for (auto x : ans) cout << v[x] << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
