#include <bits/stdc++.h>
using namespace std;
string sz[] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int ans[111111];
int n;
int cnt[11];
int id[111111];
map<string, int> mp;
int id1[111111], id2[111111];
void init() {
  mp["S"] = 0;
  mp["M"] = 1;
  mp["L"] = 2;
  mp["XL"] = 3;
  mp["XXL"] = 4;
  mp["XXXL"] = 5;
}
void go(string s, int dd) {
  string s1 = s, s2 = "";
  for (int i = 0; i < (int)s.size(); ++i) {
    if (s[i] == ',') {
      s1 = s.substr(0, i);
      s2 = s.substr(i + 1, (int)s.size() - i - 1);
    }
  }
  id1[dd] = mp[s1];
  if (s2 != "") id2[dd] = mp[s2];
}
bool cmp(int i, int j) { return id1[i] < id1[j]; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 0; i < 6; ++i) {
    cin >> cnt[i];
  }
  init();
  memset(id2, -1, sizeof id2);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    go(s, i);
    if (id2[i] == -1) {
      if (cnt[id1[i]] == 0) {
        cout << "NO";
        return 0;
      }
      cnt[id1[i]]--;
      ans[i] = id1[i];
    }
    id[i] = i;
  }
  sort(id, id + n, cmp);
  for (int i = 0; i < n; ++i) {
    if (id2[id[i]] != -1) {
      if (cnt[id1[id[i]]] != 0) {
        cnt[id1[id[i]]]--;
        ans[id[i]] = id1[id[i]];
      } else if (cnt[id2[id[i]]] != 0) {
        cnt[id2[id[i]]]--;
        ans[id[i]] = id2[id[i]];
      } else {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES\n";
  for (int i = 0; i < n; ++i) {
    cout << sz[ans[i]] + "\n";
  }
  return 0;
}
