#include <bits/stdc++.h>
using namespace std;
int cnt[6];
string res[100005];
map<string, int> mymap;
vector<int> Split(const string &s) {
  vector<int> res;
  string tmp;
  for (char x : s) {
    if (x == ',')
      res.push_back(mymap[tmp]), tmp = "";
    else
      tmp.push_back(x);
  }
  res.push_back(mymap[tmp]);
  return res;
}
int main() {
  iostream::sync_with_stdio(false);
  cin.tie(0);
  int n;
  for (int i = 0; i <= 5; ++i) cin >> cnt[i];
  mymap["S"] = 0;
  mymap["M"] = 1;
  mymap["L"] = 2;
  mymap["XL"] = 3;
  mymap["XXL"] = 4;
  mymap["XXXL"] = 5;
  map<int, string> nani;
  for (auto x : mymap) nani[x.second] = x.first;
  vector<pair<int, int> > later;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    string s;
    cin >> s;
    auto u = Split(s);
    if (u.size() == 1) {
      --cnt[u[0]];
      res[i] = s;
    } else
      later.push_back({u[0], i});
  }
  sort(later.begin(), later.end());
  for (auto x : later) {
    int v = x.first;
    assert(v < 5);
    if (cnt[v] > 0)
      --cnt[v], res[x.second] = nani[v];
    else
      --cnt[v + 1], res[x.second] = nani[v + 1];
  }
  for (int i = 0; i <= 5; ++i)
    if (cnt[i] < 0) return !(cout << "NO");
  cout << "YES\n";
  for (int i = 1; i <= n; ++i) cout << res[i] << '\n';
  return 0;
}
