#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    string a[] = {"S", "M", "L", "XL", "XXL", "XXXL"};
    map<string, int> ct;
    vector<pair<string, string> > b;
    for (long long int i = 0; i < 6; i++) cin >> ct[a[i]];
    int n;
    cin >> n;
    vector<string> ans(n);
    fill((ans).begin(), (ans).end(), "null");
    for (long long int i = 0; i < n; i++) {
      string s, s1, s2;
      cin >> s;
      int k = 0;
      while (s[k] != ',' && k < (long long int)s.size()) {
        s1.push_back(s[k]);
        k++;
      }
      if (s[k] != ',') {
        ans[i] = s1;
        ct[s1]--;
        if (ct[s1] < 0) {
          cout << "NO";
          return 0;
        }
        b.push_back({s1, "Vf"});
        continue;
      }
      k++;
      while (k < (long long int)s.size()) {
        s2.push_back(s[k]);
        k++;
      }
      b.push_back({s1, s2});
    }
    for (long long int i = 0; i < 6; i++) {
      for (long long int j = 0; j < n; j++) {
        if (b[j].second == a[i]) {
          if (ct[a[i]] > 0 && ans[j] == "null") {
            ans[j] = a[i];
            ct[a[i]]--;
          }
        }
      }
      for (long long int j = 0; j < n; j++) {
        if (b[j].first == a[i]) {
          if (ct[a[i]] > 0 && ans[j] == "null") {
            ans[j] = a[i];
            ct[a[i]]--;
          }
        }
      }
    }
    for (long long int i = 0; i < n; i++) {
      if (ans[i] == "null") {
        cout << "NO";
        return 0;
      }
    }
    cout << "YES\n";
    for (long long int i = 0; i < n; i++) cout << ans[i] << '\n';
  }
  return 0;
}
