#include <bits/stdc++.h>
using namespace std;
const int iinf = 1e9 + 7;
const long long linf = 1ll << 60;
const double dinf = 1e10;
inline long long read() {
  bool f = 0;
  long long x = 0;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') {
    f = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  if (f) x = -x;
  return x;
}
inline void scf(int &x) {
  bool f = 0;
  x = 0;
  char c = getchar();
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') {
    f = 1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  if (f) x = -x;
  return;
}
void scf(int &x, int &y) {
  scf(x);
  return scf(y);
}
void scf(int &x, int &y, int &z) {
  scf(x);
  scf(y);
  return scf(z);
}
const int N = 1e5 + 100;
int n;
string ans[N];
vector<pair<pair<int, int>, int> > tsh;
map<string, int> _hash;
int cnt[N];
const string out[] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int main() {
  for (int i = 0; i < (6); i++) cin >> cnt[i];
  cin >> n;
  _hash["S"] = 0;
  _hash["M"] = 1;
  _hash["L"] = 2;
  _hash["XL"] = 3;
  _hash["XXL"] = 4;
  _hash["XXXL"] = 5;
  for (int i = 0; i < (n); i++) {
    string s;
    cin >> s;
    int j = 0;
    while (j < (int)s.size() && s[j] != ',') j++;
    if (j == (int)s.size()) {
      ans[i] = s;
      cnt[_hash[s]]--;
      continue;
    }
    string s1 = s.substr(0, j), s2 = s.substr(j + 1);
    int i1 = _hash[s1], i2 = _hash[s2];
    if (i1 > i2) swap(i1, i2);
    tsh.push_back(make_pair(make_pair(i1, i2), i));
  }
  for (int i = 0; i < (6); i++)
    if (cnt[i] < 0) {
      puts("NO");
      return 0;
    }
  sort(tsh.begin(), tsh.end());
  for (auto x : tsh) {
    int i1 = x.first.first, i2 = x.first.second, i = x.second;
    if (cnt[i1] > 0)
      cnt[i1]--, ans[i] = out[i1];
    else
      cnt[i2]--, ans[i] = out[i2];
  }
  for (int i = 0; i < (6); i++)
    if (cnt[i] < 0) {
      puts("NO");
      return 0;
    }
  puts("YES");
  for (int i = 0; i < (n); i++) cout << ans[i] << endl;
  return 0;
}
