#include <bits/stdc++.h>
using namespace std;
inline void operator+=(pair<int, int> &a, pair<int, int> b) {
  a.first += b.first;
  a.second += b.second;
}
template <typename T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
const double eps = 1e-9;
const int MAXN = (int)2e5 + 256;
const int MOD = (int)1e9 + 7, INF = (int)1e9;
const long long INFLL = (long long)1e18;
int n, k;
struct edge {
  long long v, u, cap, flow;
};
vector<int> g[MAXN];
vector<edge> e;
int ptr[MAXN], d[MAXN];
inline void addEdge(int v, int u, long long cap) {
  e.push_back({v, u, cap, 0});
  e.push_back({u, v, 0, 0});
  g[v].push_back((int)e.size() - 2);
  g[u].push_back((int)e.size() - 1);
}
inline bool bfs(int s, int t) {
  queue<int> q;
  q.push(s);
  for (int i = 1; i <= t; ++i) d[i] = -1;
  d[s] = 0;
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (auto id : g[v]) {
      int to = e[id].u;
      if (e[id].flow == e[id].cap) continue;
      if (d[to] == -1) {
        d[to] = d[v] + 1;
        q.push(to);
      }
    }
  }
  return d[t] != -1;
}
long long dfs(int v, int t, long long push = INT_MAX) {
  if (!push || v == t) return push;
  for (int &id = ptr[v]; id < g[v].size(); ++id) {
    int td = g[v][id];
    int to = e[td].u;
    if (e[td].flow == e[td].cap) continue;
    if (d[to] != d[v] + 1) continue;
    long long pushed = dfs(to, t, min(push, 1ll * e[td].cap - e[td].flow));
    if (pushed) {
      e[td].flow += pushed;
      e[td ^ 1].flow -= pushed;
      return pushed;
    }
  }
  return 0;
}
inline long long DinitZ(int s, int t) {
  long long res = 0;
  while (bfs(s, t)) {
    while (long long pushed = dfs(s, t)) res += pushed;
    memset(ptr, 0, sizeof ptr);
  }
  return res;
}
int cnt[7];
inline int ggg(const string &s) {
  if (s == "S") return 1;
  if (s == "M") return 2;
  if (s == "L") return 3;
  if (s == "XL") return 4;
  if (s == "XXL") return 5;
  if (s == "XXXL") return 6;
}
inline string ttt(int s) {
  if (s == 1) return "S";
  if (s == 2) return "M";
  if (s == 3) return "L";
  if (s == 4) return "XL";
  if (s == 5) return "XXL";
  if (s == 6) return "XXXL";
}
vector<int> sss[MAXN];
int ans[MAXN];
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 1; i <= 6; ++i) cin >> cnt[i];
  cin >> n;
  vector<pair<int, pair<int, int> > > q;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    vector<int> v;
    string t;
    for (int i = 0; i < s.size(); ++i) {
      if (isalpha(s[i]))
        t += s[i];
      else {
        v.push_back(ggg(t));
        t = "";
      }
    }
    v.push_back(ggg(t));
    if (v.size() == 1) {
      cnt[v[0]]--;
    } else {
      q.push_back(make_pair(i, make_pair(v[0], v[1])));
    }
    sss[i] = v;
  }
  for (int i = 1; i <= 6; ++i)
    if (cnt[i] < 0) cout << "NO", exit(0);
  int ss = n + 6 + 1, tt = n + 6 + 2;
  for (int i = 1; i <= 6; ++i) {
    addEdge(ss, i, cnt[i]);
  }
  for (auto it : q) {
    addEdge(it.second.first, 6 + it.first + 1, 1);
    addEdge(it.second.second, 6 + it.first + 1, 1);
  }
  for (int i = 1; i <= n; ++i) addEdge(6 + i, tt, 1);
  int x = DinitZ(ss, tt);
  if (x == q.size()) {
    for (auto it : e) {
      if (it.flow == 1 && it.cap == 1 && 1 <= it.v && it.v <= 6) {
        ans[it.u - 6] = it.v;
      }
    }
    cout << "YES\n";
    for (int i = 0; i < n; ++i) {
      if (sss[i].size() == 1) {
        cout << ttt(sss[i][0]) << '\n';
      } else {
        cout << ttt(ans[i + 1]) << '\n';
      }
    }
  } else {
    cout << "NO\n";
  }
  return 0;
}
