#include <bits/stdc++.h>
using namespace std;
const long long one = 1;
const long long INF = 2e18;
const long long MOD = 1e9 + 7;
const long long N = 40040 + 10;
const long long nul = 0;
signed main() {
  vector<long long> cnt(6);
  for (long long &i : cnt) cin >> i;
  vector<pair<pair<long long, long long>, long long> > smth;
  long long n;
  cin >> n;
  map<string, long long> dict;
  dict["S"] = 0;
  dict["M"] = 1;
  dict["L"] = 2;
  dict["XL"] = 3;
  dict["XXL"] = 4;
  dict["XXXL"] = 5;
  bool can = 0;
  vector<string> sz = {"S", "M", "L", "XL", "XXL", "XXXL"};
  vector<string> ans(n);
  for (long long i = 0; i < n; i++) {
    string s;
    cin >> s;
    string now = "";
    pair<long long, long long> q;
    bool flag = 0;
    for (char i : s) {
      if (i == ',') {
        q.first = dict[now];
        now = "";
        flag = 1;
      } else {
        now += i;
      }
    }
    if (flag) {
      q.second = dict[now];
      if (q.second < q.first) {
        swap(q.first, q.second);
      }
      smth.push_back({q, i});
    } else {
      if (cnt[dict[now]] == 0) {
        can = 1;
      } else {
        cnt[dict[now]]--;
        ans[i] = now;
      }
    }
  }
  if (can)
    cout << "NO\n";
  else {
    sort((smth).begin(), (smth).end());
    for (auto i : smth) {
      long long one = i.first.first, two = i.first.second;
      if (cnt[one] == 0) {
        if (cnt[two] == 0) {
          can = 1;
          break;
        } else {
          ans[i.second] = sz[two];
          cnt[two]--;
        }
      } else {
        ans[i.second] = sz[one];
        cnt[one]--;
      }
    }
    if (can)
      cout << "NO\n";
    else {
      cout << "YES\n";
      for (auto i : ans) cout << i << endl;
    }
  }
}
