#include <bits/stdc++.h>
using namespace std;
const int D = 6;
string p[D] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int which(string s) {
  for (int i = 0; i < D; i++)
    if (p[i] == s) return i;
  assert(false);
}
int cnt[D];
const int MX = 100 * 1000 + 999;
string ans[MX];
int n;
vector<int> pairs[D - 1];
bool solve() {
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    auto pos = s.find(',');
    if (pos == string::npos) {
      int idx = which(s);
      if (cnt[idx] <= 0) return false;
      cnt[idx]--;
      ans[i] = s;
    } else {
      assert(s[pos] == ',');
      s = s.substr(0, pos);
      pairs[which(s)].push_back(i);
    }
  }
  for (int i = 0; i < D - 1; i++) {
    for (auto idx : pairs[i]) {
      if (cnt[i] > 0) {
        cnt[i]--;
        ans[idx] = p[i];
      } else if (cnt[i + 1] > 0) {
        cnt[i + 1]--;
        ans[idx] = p[i + 1];
      } else
        return false;
    }
  }
  return true;
}
int main() {
  for (int i = 0; i < D; i++) cin >> cnt[i];
  cin >> n;
  if (solve()) {
    cout << "YES\n";
    for (int i = 0; i < n; i++) cout << ans[i] << '\n';
  } else
    cout << "NO";
  return 0;
}
