#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
namespace input {
inline int nextInt() {
  int res = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') res = res * 10 + c - '0', c = getchar();
  return res;
}
inline long long nextLong() {
  long long res = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') res = res * 10 + c - '0', c = getchar();
  return res;
}
inline bool isSpace(const char &c) {
  return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
inline void next(char *str) {
  char c = getchar();
  while (isSpace(c)) c = getchar();
  size_t head = 0;
  while (!isSpace(c)) str[head++] = c, c = getchar();
  str[head] = 0;
}
inline char nextChar() {
  char c = getchar();
  while (isSpace(c)) c = getchar();
  return c;
}
}  // namespace input
using namespace input;
const int N = 2e5 + 5;
int n;
int t[N];
int cnt[100];
char buf[N];
int q[N];
int w[N];
int ans[N];
vector<int> b[100];
vector<int> o[100];
vector<string> fs = {"S", "M", "L", "XL", "XXL", "XXXL"};
void bad() {
  puts("NO");
  exit(0);
}
void solve() {
  for (int i = 0; i < 6; i++) {
    scanf("%d", cnt + i);
  }
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", buf);
    string temp = buf;
    string a = "";
    int j = 0;
    for (; j < temp.size() && temp[j] != ','; j++) {
      a += temp[j];
    }
    for (int k = 0; k < fs.size(); k++) {
      if (fs[k] == a) {
        q[i] = k;
        if (j != temp.size()) {
          w[i] = 1;
          b[k].push_back(i);
        } else {
          o[k].push_back(i);
        }
      }
    }
  }
  for (int t = 0; t < 6; t++) {
    for (int i = 0; i < o[t].size(); i++) {
      ans[o[t][i]] = t;
      cnt[t]--;
    }
    if (cnt[t] < 0) {
      bad();
    }
    int i = 0;
    for (; cnt[t] && i < b[t].size(); i++) {
      ans[b[t][i]] = t;
      cnt[t]--;
    }
    if (i != b[t].size()) {
      for (; i < b[t].size(); i++) {
        o[t + 1].push_back(b[t][i]);
      }
    }
  }
  puts("YES");
  for (int i = 0; i < n; i++) {
    printf("%s\n", fs[ans[i]].c_str());
  }
}
