#include <bits/stdc++.h>
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long MAX5 = 1e+5 + 7;
const long long MAX7 = 1e+7 + 7;
const long long MAXN = MAX7;
const long long INF = 0x7f7f7f7f7f7f7f7f;
const int INFi = 0x7f7f7f7f;
const long long MOD = 998244353;
long long t = 1;
long long n;
string second;
vector<string> removeDupWord(string str) {
  vector<string> val;
  string word = "";
  for (auto x : str) {
    if (x == ',') {
      val.push_back(word);
      word = "";
    } else {
      word = word + x;
    }
  }
  val.push_back(word);
  return val;
}
void MAIN() {
  vector<long long> size(6);
  for (long long i = 0; i < 6; i++) cin >> size[i];
  map<long long, string> indx;
  indx[0] = "S";
  indx[1] = "M";
  indx[2] = "L";
  indx[3] = "XL";
  indx[4] = "XXL";
  indx[5] = "XXXL";
  cin >> n;
  vector<string> val[n];
  vector<string> ans(n, "-");
  for (long long i = 0; i < n; i++) {
    cin >> second;
    val[i] = removeDupWord(second);
  }
  for (long long k = 0; k < 6; k++) {
    second = indx[k];
    for (long long i = 0; i < n; i++) {
      if (val[i].size() == 1 && val[i][0] == second) {
        if (size[k]) {
          size[k]--;
          ans[i] = second;
        } else {
          cout << "NO\n";
          return;
        }
      }
    }
    for (long long i = 0; i < n; i++) {
      if (val[i].size() == 2 && val[i][1] == second && ans[i] == "-") {
        if (size[k]) {
          size[k]--;
          ans[i] = second;
        } else {
          cout << "NO\n";
          return;
        }
      }
    }
    for (long long i = 0; i < n; i++) {
      if (val[i].size() == 2 && val[i][0] == second) {
        if (size[k]) {
          size[k]--;
          ans[i] = second;
        }
      }
    }
  }
  cout << "YES\n";
  for (long long i = 0; i < n; i++) cout << ans[i] << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed;
  cout << setprecision(12);
  ;
  mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
  ;
  while (t--) {
    MAIN();
  }
  return 0;
}
