#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, a[6], d[N], val[N];
string result[N];
string ids[] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int getId(string s) {
  for (int i = 0; i < 6; ++i)
    if (s == ids[i]) return i;
  return -1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  for (int i = 0; i < 6; ++i) cin >> a[i];
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    int pos = s.find(',');
    if (pos == (int)string::npos) {
      --a[getId(s)];
      result[i] = s;
    } else {
      d[i] = true;
      val[i] = getId(s.substr(0, pos));
    }
  }
  for (int i = 0; i < 6; ++i) {
    for (int j = 0; j < n; ++j) {
      if (d[j] && val[j] == i) {
        if (a[i] > 0) {
          d[j] = false;
          --a[i];
          result[j] = ids[i];
        } else {
          --a[i + 1];
          result[j] = ids[i + 1];
        }
        d[j] = false;
      }
    }
  }
  for (int i = 0; i < 6; ++i)
    if (a[i] < 0) {
      cout << "NO" << endl;
      exit(0);
    }
  for (int i = 0; i < n; ++i)
    if (d[i]) {
      cout << "NO" << endl;
      exit(0);
    }
  cout << "YES" << endl;
  for (int i = 0; i < n; ++i) cout << result[i] << '\n';
  return 0;
}
