#include <bits/stdc++.h>
using namespace std;
int N, cho[(100010)], num[8];
map<string, int> M;
vector<int> vec[(100010)], can[8];
string sze[8];
inline bool judge() {
  for (int i = 1; i <= N; ++i) {
    if (vec[i].size() == 1) {
      if (num[vec[i][0]])
        num[vec[i][0]]--, cho[i] = vec[i][0];
      else
        return false;
    } else {
      if (vec[i][0] > vec[i][1]) swap(vec[i][0], vec[i][1]);
      can[vec[i][0]].push_back(i);
    }
  }
  for (int i = 1; i <= 5; ++i)
    for (int j = 0; j < can[i].size(); ++j)
      for (int k = 0; k < 2; ++k)
        if (num[vec[can[i][j]][k]]) {
          num[vec[can[i][j]][k]]--, cho[can[i][j]] = vec[can[i][j]][k];
          break;
        }
  for (int i = 1; i <= N; ++i)
    if (!cho[i]) return false;
  return true;
}
int main() {
  for (int i = 1; i <= 6; ++i) scanf("%d", num + i);
  sze[1] = "S";
  sze[2] = "M";
  sze[3] = "L";
  sze[4] = "XL";
  sze[5] = "XXL";
  sze[6] = "XXXL";
  for (int i = 1; i <= 6; ++i) M[sze[i]] = i;
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    string s;
    cin >> s;
    int l = s.length(), j;
    for (j = 0; j < l; ++j)
      if (s[j] == ',') break;
    if (j == l)
      vec[i].push_back(M[s]);
    else {
      string t;
      t = s.substr(j + 1);
      s.erase(j);
      vec[i].push_back(M[s]);
      vec[i].push_back(M[t]);
    }
  }
  if (!judge())
    puts("NO");
  else {
    puts("YES");
    for (int i = 1; i <= N; ++i) cout << sze[cho[i]] << endl;
  }
  return 0;
}
