#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int mark[10] = {0};
  map<string, int> mp;
  mp["S"] = 0;
  mp["M"] = 1;
  mp["L"] = 2;
  mp["XL"] = 3;
  mp["XXL"] = 4;
  mp["XXXL"] = 5;
  for (int i = 0; i < 6; i++) {
    cin >> mark[i];
  }
  int n;
  cin >> n;
  vector<pair<int, pair<int, int> > > vt;
  int ans[n + 5];
  for (int i = 0; i < n; i++) {
    string tem;
    cin >> tem;
    string a, b;
    int f;
    for (int i = 0; i < tem.length(); i++) {
      if (tem[i] == ',') {
        f = i + 1;
        break;
      }
      a.push_back(tem[i]);
    }
    for (int i = f; i < tem.length(); i++) {
      b.push_back(tem[i]);
    }
    if (!b.length()) {
      ans[i] = mp[a];
      mark[mp[a]]--;
    } else {
      vt.push_back(make_pair(mp[a], make_pair(mp[b], i)));
    }
  }
  sort(vt.begin(), vt.end());
  int f = 0;
  for (auto data : vt) {
    int a = data.first;
    int b = data.second.first;
    int id = data.second.second;
    if (mark[a] > 0) {
      mark[a]--;
      ans[id] = a;
    } else if (mark[b] > 0) {
      ans[id] = b;
      mark[b]--;
    } else {
      f = 1;
    }
  }
  for (int i = 0; i < 6; i++)
    if (mark[i] < 0) f = 1;
  if (f == 1)
    cout << "NO\n";
  else {
    cout << "YES\n";
    for (int i = 0; i < n; i++) {
      if (ans[i] == 0) cout << "S\n";
      if (ans[i] == 1) cout << "M\n";
      if (ans[i] == 2) cout << "L\n";
      if (ans[i] == 3) cout << "XL\n";
      if (ans[i] == 4) cout << "XXL\n";
      if (ans[i] == 5) cout << "XXXL\n";
    }
  }
  return 0;
}
