#include <bits/stdc++.h>
using namespace std;
map<string, int> m;
int main() {
  int n;
  cin >> m["S"];
  cin >> m["M"];
  cin >> m["L"];
  cin >> m["XL"];
  cin >> m["XXL"];
  cin >> m["XXXL"];
  cin >> n;
  vector<string> p;
  for (int i = 1; i <= n; i++) {
    string t;
    cin >> t;
    p.push_back(t);
  }
  vector<string> ans(200000);
  for (int i = 0; i < p.size(); i++) {
    if (p[i].find(',') == string::npos) {
      m[p[i]]--;
      ans[i] = p[i];
    }
  }
  for (int i = 0; i < p.size(); i++) {
    if (p[i].find(',') != string::npos) {
      if (p[i] == "S,M") {
        ans[i] = (m["S"] > 0 ? "S" : "M");
        m[(m["S"] > 0 ? "S" : "M")]--;
      }
    }
  }
  for (int i = 0; i < p.size(); i++) {
    if (p[i].find(',') != string::npos) {
      if (p[i] == "M,L") {
        ans[i] = (m["M"] > 0 ? "M" : "L");
        m[(m["M"] > 0 ? "M" : "L")]--;
      }
    }
  }
  for (int i = 0; i < p.size(); i++) {
    if (p[i].find(',') != string::npos) {
      if (p[i] == "XXL,XXXL") {
        ans[i] = (m["XXXL"] > 0 ? "XXXL" : "XXL");
        m[(m["XXXL"] > 0 ? "XXXL" : "XXL")]--;
      }
    }
  }
  for (int i = 0; i < p.size(); i++) {
    if (p[i].find(',') != string::npos) {
      if (p[i] == "XL,XXL") {
        ans[i] = (m["XXL"] > 0 ? "XXL" : "XL");
        m[(m["XXL"] > 0 ? "XXL" : "XL")]--;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (p[i] == "L,XL") {
      ans[i] = (m["L"] > m["XL"] ? "L" : "XL");
      m[(m["L"] > m["XL"] ? "L" : "XL")]--;
    }
  }
  for (auto i : m) {
    if (i.second < 0) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES\n";
  for (int i = 0; i < n; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}
