#include <bits/stdc++.h>
using namespace std;
string busca(const string &S) {
  for (int i = 0; i < S.size(); i++)
    if (S[i] == ',') return S.substr(0, i);
  return "";
}
string t_shirts[] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  const int SIZE = 6;
  vector<int> TS(SIZE);
  for (int i = 0; i < SIZE; i++) cin >> TS[i];
  int N;
  cin >> N;
  map<string, int> ID;
  ID["S"] = 0;
  ID["M"] = 1;
  ID["L"] = 2;
  ID["XL"] = 3;
  ID["XXL"] = 4;
  ID["XXXL"] = 5;
  vector<int> SOL(N);
  vector<pair<int, int> > V;
  for (int i = 0; i < N; i++) {
    string aux;
    cin >> aux;
    string ret = busca(aux);
    if (ret == "") {
      TS[ID[aux]]--;
      SOL[i] = ID[aux];
    } else {
      int tmp = ID[ret];
      V.push_back(make_pair(tmp, i));
    }
  }
  sort(V.begin(), V.end());
  for (int i = 0; i < V.size(); i++) {
    int tmp = V[i].first;
    if (TS[tmp] <= 0) tmp++;
    TS[tmp]--;
    SOL[V[i].second] = tmp;
  }
  bool yes = *min_element(TS.begin(), TS.end()) >= 0;
  if (!yes)
    cout << "NO\n";
  else {
    cout << "YES\n";
    for (int i = 0; i < N; i++) cout << t_shirts[SOL[i]] << '\n';
  }
  return 0;
}
