#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  map<string, int> mp;
  vector<int> cnt(6, 0);
  mp["S"] = 0;
  mp["M"] = 1;
  mp["L"] = 2;
  mp["XL"] = 3;
  mp["XXL"] = 4;
  mp["XXXL"] = 5;
  vector<string> out{"S", "M", "L", "XL", "XXL", "XXXL"};
  for (int i = 0; i < 6; ++i) {
    cin >> cnt[i];
  }
  cin >> n;
  vector<string> v(n);
  vector<pair<pair<int, int>, int> > p;
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    size_t j = v[i].find(',');
    if (j != std::string::npos) {
      v[i][j] = ' ';
      stringstream ss(v[i]);
      string t;
      ss >> v[i] >> t;
      p.push_back({{mp[v[i]], mp[t]}, i});
    } else if (cnt[mp[v[i]]]) {
      --cnt[mp[v[i]]];
    } else {
      cout << "NO\n";
      return 0;
    }
  }
  sort(p.begin(), p.end());
  for (int i = 0; i < (int)p.size(); ++i) {
    if (cnt[p[i].first.first]) {
      --cnt[p[i].first.first];
      v[p[i].second] = out[p[i].first.first];
    } else if (cnt[p[i].first.second]) {
      --cnt[p[i].first.second];
      v[p[i].second] = out[p[i].first.second];
    } else {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  for (int i = 0; i < n; ++i) {
    cout << v[i] << '\n';
  }
  return 0;
}
