#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int n, m, n2;
int a[N];
int b[10];
map<string, int> mp;
string res[10];
int out[N];
class Dinic {
 public:
  struct Edge {
    int from, to, cap, flow;
    Edge(int _from = -1, int _to = -1, int _cap = 0, int _flow = 0)
        : from(_from), to(_to), cap(_cap), flow(_flow) {}
  };
  int n;
  vector<vector<int> > g;
  vector<vector<int>::iterator> work;
  vector<Edge> edges;
  vector<int> level;
  void init(int _n) {
    n = _n;
    g.assign(_n, vector<int>());
    work.assign(_n, vector<int>::iterator());
    edges.clear();
    level.resize(_n);
  }
  void addEdge(int u, int v, int cap, bool twoWay) {
    g[u].push_back((int)edges.size());
    edges.push_back(Edge(u, v, cap, 0));
    g[v].push_back((int)edges.size());
    edges.push_back(Edge(v, u, (twoWay == true) ? cap : 0, 0));
  }
  void resetFlows() {
    for (int i = 0; i < (int)edges.size(); ++i) edges[i].flow = 0;
  }
  bool bfs(int s, int t) {
    level = vector<int>(n, -1);
    queue<int> q;
    q.push(s);
    level[s] = 0;
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (__typeof(g[u].begin()) it = g[u].begin(); it != g[u].end(); ++it) {
        int e = *it;
        int v = edges[e].to;
        if (level[v] == -1 && edges[e].flow < edges[e].cap) {
          level[v] = level[u] + 1;
          q.push(v);
        }
      }
    }
    return (level[t] != -1);
  }
  int dfs(int s, int t, int f) {
    if (s == t) return f;
    for (vector<int>::iterator &e = work[s]; e != g[s].end(); ++e) {
      int v = edges[*e].to;
      if (level[v] == level[s] + 1 && edges[*e].flow < edges[*e].cap) {
        int d = dfs(v, t, min(f, edges[*e].cap - edges[*e].flow));
        if (d > 0) {
          edges[*e].flow += d;
          edges[*e ^ 1].flow -= d;
          return d;
        }
      }
    }
    return 0;
  }
  int maxFlow(int s, int t) {
    int ret = 0;
    while (bfs(s, t)) {
      for (int i = 0; i < n; ++i) work[i] = g[i].begin();
      for (int d; (d = dfs(s, t, numeric_limits<int>::max())) != 0; ret += d)
        ;
    }
    return ret;
  }
  void solve(int s, int t) {
    int value = maxFlow(s, t);
    if (value != n2) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
      for (int i = 0; i < (int)edges.size(); ++i) {
        int u = edges[i].from;
        int v = edges[i].to;
        int flow = edges[i].flow;
        if (1 <= u && u <= 6 && 6 < v && v <= 6 + n2 && flow > 0) {
          out[v - 7] = u;
        }
      }
      for (int i = 0; i < n2; ++i) cout << res[out[i]] << "\n";
    }
  }
} netWork;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 0; i < 6; ++i) cin >> b[i];
  mp["S"] = 1;
  res[1] = "S";
  mp["M"] = 2;
  res[2] = "M";
  mp["L"] = 3;
  res[3] = "L";
  mp["XL"] = 4;
  res[4] = "XL";
  mp["XXL"] = 5;
  res[5] = "XXL";
  mp["XXXL"] = 6;
  res[6] = "XXXL";
  cin >> n;
  n2 = n;
  int s = 0, t = 6 + n + 1;
  netWork.init(t + 1);
  for (int i = 1; i <= 6; ++i) {
    netWork.addEdge(s, i, b[i - 1], false);
  }
  for (int i = 0; i < n; ++i) {
    string s, tt;
    cin >> s;
    tt.clear();
    int j = 0;
    for (; j < int(s.size()) && s[j] != ','; ++j) {
      tt.push_back(s[j]);
    }
    netWork.addEdge(mp[tt], 6 + i + 1, 1, false);
    if (j < int(s.size())) {
      tt.clear();
      j++;
      for (; j < int(s.size()); ++j) tt.push_back(s[j]);
      netWork.addEdge(mp[tt], 6 + i + 1, 1, false);
    }
    netWork.addEdge(6 + i + 1, t, 1, false);
  }
  netWork.solve(s, t);
  return 0;
}
