#include <bits/stdc++.h>
using namespace std;
vector<string> vec_splitter(string s) {
  for (char& c : s) c = c == ',' ? ' ' : c;
  stringstream ss;
  ss << s;
  vector<string> res;
  for (string z; ss >> z; res.push_back(z))
    ;
  return res;
}
void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
  if (idx > 0) cerr << ", ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, T...);
}
void localTest() {}
const long long N = 1e5 + 5;
vector<string> V[N];
vector<string> ts = {"S", "M", "L", "XL", "XXL", "XXXL"};
map<string, long long> tidx;
map<long long, string> ans;
int main() {
  localTest();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long cnt = 0;
  for (auto u : ts) tidx[u] = cnt++;
  vector<long long> tcnt(6, 0);
  for (long long i = 0; i <= 5; ++i) cin >> tcnt[i];
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    string s, aux = "";
    cin >> s;
    for (auto u : s) {
      if (u == ',')
        V[i].push_back(aux), aux = "";
      else
        aux += u;
    }
    V[i].push_back(aux);
    long long sz = V[i].size(), idx = tidx[V[i][0]];
    if (sz == 1) tcnt[idx]--, ans[i] = ts[idx];
  }
  for (long long t = 0; t <= 5; ++t) {
    for (long long i = 1; i <= n; ++i) {
      if (ans.find(i) != ans.end()) continue;
      string fi = V[i][0], se = V[i][1];
      if (fi == ts[t]) {
        if (tcnt[t] > 0) {
          ans[i] = ts[t];
          tcnt[t]--;
        } else if (tcnt[tidx[se]] > 0) {
          ans[i] = ts[tidx[se]];
          tcnt[tidx[se]]--;
        } else {
          cout << "NO\n";
          return 0;
        }
      }
    }
  }
  long long fl = 1;
  for (long long i = 0; i <= 5; ++i)
    if (tcnt[i] < 0) fl = 0;
  if (!fl)
    cout << "NO\n";
  else {
    cout << "YES\n";
    for (long long i = 1; i <= n; ++i) cout << ans[i] << "\n";
  }
  return 0;
}
