#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#pragma GCC optimize("fast-math")
using namespace std;
const int INF = 1e9;
const long long INFll = 2e18;
const int BASE1 = 179;
const int BASE2 = 653;
const long long MOD = 1e9 + 7;
const int MAXN = 2e5;
const long double PI = 3.1415926535;
const long double EPS = 1e-15;
vector<string> m1 = {"S",  "S,M",    "M",   "M,L",      "L",   "L,XL",
                     "XL", "XL,XXL", "XXL", "XXL,XXXL", "XXXL"};
bool cmp(pair<string, int> a, pair<string, int> b) {
  return (find(m1.begin(), m1.end(), a.first) - m1.begin()) <
         (find(m1.begin(), m1.end(), b.first) - m1.begin());
}
void solve() {
  vector<int> cnt(6);
  for (int i = 0; i < (6); i++) cin >> cnt[i];
  map<string, int> m = {{"S", 0},  {"M", 1},   {"L", 2},
                        {"XL", 3}, {"XXL", 4}, {"XXXL", 5}};
  vector<string> dop;
  int n;
  cin >> n;
  vector<pair<string, int>> a(n);
  for (int i = 0; i < (n); i++) {
    string s;
    cin >> s;
    a[i] = make_pair(s, i);
  }
  sort(a.begin(), a.end(), cmp);
  vector<string> res(n, "###");
  for (int i = 0; i < (n); i++) {
    string s = a[i].first;
    if (s.find(',')) {
      string s1 = s.substr(0, s.find(','));
      string s2 =
          s.substr(s.find(',') + 1, ((int)(s).size()) - ((int)(s1).size()) - 1);
      if (cnt[m[s1]] > 0) {
        cnt[m[s1]]--;
        res[a[i].second] = s1;
      } else if (cnt[m[s2]] > 0) {
        cnt[m[s2]]--;
        res[a[i].second] = s2;
      }
    } else {
      if (cnt[m[s]] > 0) {
        cnt[m[s]]--;
        res[a[i].second] = s;
      }
    }
  }
  bool flag = true;
  for (int i = 0; i < (n); i++) {
    if (res[i] == "###") flag = false;
  }
  if (flag) {
    cout << "YES\n";
    for (int i = 0; i < (n); i++) cout << res[i] << "\n";
  } else
    cout << "NO\n";
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(14) << fixed;
  int t = 1;
  while (t--) solve();
  return 0;
}
