#include <bits/stdc++.h>
using namespace std;
unordered_map<string, int> M;
string ss[6] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int n, m = 6, a[100010], L[100010];
vector<int> ke[10];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 1; i <= 6; i++) M[ss[i - 1]] = i;
  for (int i = 1; i <= m; i++) cin >> a[i];
  vector<pair<int, int> > v;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    bool kt = true;
    for (int i = 0, _v = s.size(); i < _v; i++) {
      if (s[i] == ',') {
        s[i] = ' ';
        kt = false;
      }
    }
    if (kt) {
      L[i] = M[s];
      a[M[s]]--;
    } else {
      stringstream sss(s);
      string s1, s2;
      sss >> s1;
      ke[M[s1]].push_back(i);
    }
  }
  for (int i = 1; i <= n; i++)
    if (a[i] < 0) {
      cout << "NO";
      return 0;
    };
  for (int i = 1; i <= 6; i++) {
    while (ke[i - 1].size() > 0) {
      int temp = ke[i - 1][ke[i - 1].size() - 1];
      ke[i - 1].pop_back();
      L[temp] = i;
      a[i]--;
    }
    if (a[i] < 0) {
      cout << "NO";
      return 0;
    };
    if (a[i] > 0) {
      while (a[i] > 0) {
        if (ke[i].size() == 0) break;
        int temp = ke[i][ke[i].size() - 1];
        ke[i].pop_back();
        L[temp] = i;
        a[i]--;
      }
    }
  }
  for (int i = 1; i <= 6; i++)
    if (ke[i].size() > 0) {
      cout << "NO";
      return 0;
    };
  cout << "YES" << '\n';
  for (int i = 1; i <= n; i++) {
    cout << ss[L[i] - 1] << '\n';
  }
}
