#include <bits/stdc++.h>
using namespace std;
long long i, j, n, t, k, d, b[100009], c[100009], y[100009], f[10];
string s[100009], ss, a[100009], x[100009], e[100009];
map<string, long long> mp;
vector<long long> v[100];
int main() {
  string name[6] = {"S", "M", "L", "XL", "XXL", "XXXL"};
  for (i = 0; i < 6; i++) mp[name[i]] = i;
  for (i = 1; i <= 6; i++) cin >> c[i];
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> s[i];
    d = 1;
    ss = "";
    for (j = 0; j < s[i].length(); j++) {
      if (s[i][j] == ',') {
        d = 0;
        break;
      }
      ss = ss + s[i][j];
    }
    if (d) {
      t++;
      a[t] = ss;
      b[t] = i;
    } else
      v[mp[ss]].push_back(i);
  }
  for (i = 0; i < 6; i++) f[mp[name[i]]] += c[i + 1];
  for (i = 1; i <= t; i++) {
    e[b[i]] = a[i];
    f[mp[a[i]]]--;
  }
  for (i = 0; i < 6; i++) {
    vector<long long>::iterator it;
    for (it = v[i].begin(); it != v[i].end(); ++it) {
      if (f[mp[name[i]]] <= 0) {
        if (f[mp[name[i]] + 1] <= 0) {
          cout << "NO";
          return 0;
        }
        f[mp[name[i]] + 1]--;
        e[*it] = name[mp[name[i]] + 1];
      } else
        f[mp[name[i]]]--, e[*it] = name[mp[name[i]]];
    }
  }
  bool ok = 1;
  for (i = 0; i < 6; i++)
    if (f[mp[name[i]]] < 0) ok = 0;
  if (ok) {
    cout << "YES" << endl;
    for (i = 1; i <= n; i++) cout << e[i] << endl;
  } else
    cout << "NO";
}
