#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
template <typename T_container, typename T = typename enable_if<
                                    !is_same<T_container, string>::value,
                                    typename T_container::value_type>::type>
ostream &operator<<(ostream &os, const T_container &v) {
  os << '{';
  string sep;
  for (const T &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
const int INF = 1 << 30;
const int MOD = 1e9 + 7;
const int MAXN = 2e5 + 5;
string asignar(int n) {
  if (n == 0) return "S";
  if (n == 1) return "M";
  if (n == 2) return "L";
  if (n == 3) return "XL";
  if (n == 4) return "XXL";
  if (n == 5) return "XXXL";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<int> stock(6);
  for (long long i = (0); i < (long long)(6); i++) cin >> stock[i];
  int n;
  cin >> n;
  vector<pair<pair<int, int>, int>> quiero(n);
  for (long long j = (0); j < (long long)(n); j++) {
    string s;
    cin >> s;
    string curr = "";
    pair<int, int> x = make_pair(-1, -1);
    for (long long i = (0); i < (long long)(s.size()); i++) {
      if (s[i] != ',') {
        curr += s[i];
      } else {
        if (curr == "S") x.first = 0;
        if (curr == "M") x.first = 1;
        if (curr == "L") x.first = 2;
        if (curr == "XL") x.first = 3;
        if (curr == "XXL") x.first = 4;
        if (curr == "XXXL") x.first = 5;
        curr = "";
      }
    }
    if (curr == "S") x.second = 0;
    if (curr == "M") x.second = 1;
    if (curr == "L") x.second = 2;
    if (curr == "XL") x.second = 3;
    if (curr == "XXL") x.second = 4;
    if (curr == "XXXL") x.second = 5;
    if (x.first == -1) x.first = x.second;
    if (x.first > x.second) swap(x.first, x.second);
    quiero[j] = make_pair(x, j);
  }
  sort((quiero).begin(), (quiero).end());
  ;
  vector<string> ans(n);
  for (long long i = (0); i < (long long)(n); i++) {
    if (stock[quiero[i].first.first] > 0) {
      ans[quiero[i].second] = asignar(quiero[i].first.first);
      stock[quiero[i].first.first]--;
    } else if (stock[quiero[i].first.second] > 0) {
      ans[quiero[i].second] = asignar(quiero[i].first.second);
      stock[quiero[i].first.second]--;
    } else {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  for (long long i = (0); i < (long long)(n); i++) cout << ans[i] << "\n";
  cout << "\n";
  return 0;
}
