#include <bits/stdc++.h>
using namespace std;
int T[6];
int C[72][72] = {0}, R[72][72] = {0}, dis[72], n, u, v, w, s, t, m;
bool BFS(int s, int t) {
  for (int i = 0; i < n; ++i) dis[i] = 1e9;
  queue<int> q;
  q.push(s);
  dis[s] = 0;
  while (!q.empty()) {
    int s = q.front();
    q.pop();
    for (int i = 0; i < n; ++i)
      if (dis[i] == 1e9 && R[s][i] > 0) dis[i] = dis[s] + 1, q.push(i);
  }
  return dis[t] != 1e9;
}
int DFS(int s, int t, int cur_flow = 1e9) {
  if (cur_flow == 0 || s == t) return cur_flow;
  int aug_flow = 0, aug = 0;
  for (int i = 0; i < n; ++i) {
    if (R[s][i] > 0 && dis[s] + 1 == dis[i]) {
      aug = DFS(i, t, min(cur_flow, R[s][i]));
      R[s][i] -= aug, R[i][s] += aug;
      aug_flow += aug;
      if (!(cur_flow -= aug)) break;
    }
  }
  return aug_flow;
}
int maximum(int s, int t) {
  int aug_sum = 0;
  while (BFS(s, t)) aug_sum += DFS(s, t);
  return aug_sum;
}
int key(string s) {
  if (s == "S") return 1;
  if (s == "M") return 2;
  if (s == "L") return 4;
  if (s == "XL") return 8;
  if (s == "XXL") return 16;
  if (s == "XXXL") return 32;
  return 0;
}
string str;
int part[100000];
string spp[6] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int main() {
  n = 72;
  for (int i = 0; i < 6; ++i) {
    scanf("%d", &T[i]);
    C[0][i + 65] = R[0][i + 65] = T[i];
  }
  int p;
  scanf("%d", &p);
  getline(cin, str);
  for (int i = 0; i < p; ++i) {
    getline(cin, str);
    int k = 0;
    auto it = str.begin(), it2 = it;
    do {
      it2 = find(it, str.end(), ',');
      k += key(string(it, it2));
      it = it2 + 1;
    } while (it2 != str.end());
    part[i] = k;
    ++R[k][71], ++C[k][71];
  }
  for (int i = 0; i < 6; ++i)
    for (int j = 1; j < 64; ++j)
      if (((j) >> i) % 2) C[i + 65][j] = R[i + 65][j] = 1e9;
  int a = maximum(0, 71);
  if (a != p)
    printf("NO");
  else {
    printf("YES\n");
    for (int i = 0; i < p; ++i) {
      int k = part[i];
      for (int j = 65; j < 71; ++j) {
        if (R[k][j]) {
          printf("%s\n", spp[j - 65].c_str());
          --R[k][j];
          break;
        }
      }
    }
  }
}
