#include <bits/stdc++.h>
using namespace std;
const int N = 5007, M = 128, mod = 1000000007, inf = 1000000007;
const long long lmod = 1000000007, linf = 1e18 + 77;
const long double eps = 1e-9;
int k[N];
vector<int> a;
vector<pair<int, int> > b;
map<string, int> num;
void bad() {
  puts("NO");
  exit(0);
}
int p[N];
int l[N], r[N];
vector<pair<string, bool> > inp;
string S[N] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int main() {
  ios_base::sync_with_stdio(0);
  num["S"] = 0;
  num["M"] = 1;
  num["L"] = 2;
  num["XL"] = 3;
  num["XXL"] = 4;
  num["XXXL"] = 5;
  for (int i = 0; i < 6; i++) {
    cin >> k[i];
  }
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    bool flag = 0;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] == ',') {
        flag = 1;
      }
    }
    if (flag) {
      while (s.back() != ',') s.pop_back();
      s.pop_back();
      p[num[s]]++;
    } else {
      a.push_back(num[s]);
    }
    inp.push_back(make_pair(s, flag));
  }
  for (int i = 0; i < a.size(); i++) {
    k[a[i]]--;
    if (k[a[i]] < 0) {
      bad();
    }
  }
  for (int i = 0; i < 5; i++) {
    if (p[i] > k[i] + k[i + 1]) {
      bad();
    } else {
      int del = min(p[i], k[i]);
      p[i] -= del;
      k[i] -= del;
      l[i] += del;
      k[i + 1] -= p[i];
      r[i] += p[i];
    }
  }
  cout << "YES" << endl;
  for (int i = 0; i < inp.size(); i++) {
    bool flag = inp[i].second;
    string s = inp[i].first;
    if (flag) {
      int nu = num[s];
      if (l[nu]) {
        cout << s << endl;
        l[nu]--;
      } else {
        cout << S[nu + 1] << endl;
        r[nu]--;
      }
    } else {
      cout << s << endl;
    }
  }
}
