#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int cnt[10];
string size[] = {"S", "M", "L", "XL", "XXL", "XXXL"};
unordered_map<string, int> id{{"S", 0},      {"M", 1},        {"L", 2},
                              {"XL", 3},     {"XXL", 4},      {"XXXL", 5},
                              {"S,M", 6},    {"M,L", 7},      {"L,XL", 8},
                              {"XL,XXL", 9}, {"XXL,XXXL", 10}};
vector<int> cnt1[10], cnt2[10];
int p[maxn];
int main() {
  for (int i = 0; i < 6; ++i) scanf("%d", cnt + i);
  int _n;
  scanf("%d", &_n);
  string line;
  for (int i = 0; i < _n; ++i) {
    cin >> line;
    int index = id[line];
    if (index < 6)
      cnt1[index].push_back(i);
    else
      cnt2[index - 6].push_back(i);
    p[i] = index;
  }
  for (int i = 0; i < 6; ++i) {
    cnt[i] -= cnt1[i].size();
    if (cnt[i] < 0) {
      cout << "NO\n";
      return 0;
    }
  }
  int pos = 0;
  for (size_t i = 0; cnt[0] > 0 && i < cnt2[0].size(); ++i) {
    p[cnt2[0][pos++]] = 0;
    cnt[0]--;
  }
  for (size_t i = 0; i < 5; ++i) {
    for (size_t j = pos; j < cnt2[i].size(); ++j) {
      cnt[i + 1]--;
      p[cnt2[i][j]] = i + 1;
    }
    if (cnt[i + 1] < 0) {
      cout << "NO\n";
      return 0;
    }
    pos = 0;
    for (size_t j = 0; cnt[i + 1] > 0 && j < cnt2[i + 1].size(); ++j) {
      cnt[i + 1]--;
      p[cnt2[i + 1][pos++]] = i + 1;
    }
  }
  if (cnt[5] < 0) {
    cout << "NO\n";
    return 0;
  } else {
    cout << "YES\n";
    for (int i = 0; i < _n; ++i) {
      cout << size[p[i]] << "\n";
    }
  }
  return 0;
}
