#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000 * 1000 * 1000 + 7;
const double PI = acos(-1.0);
long long gcd(long long a, long long b) {
  long long m;
  while (b) {
    m = a % b;
    a = b;
    b = m;
  }
  return a;
}
int rome_number(char s[]) {
  if (s[0] == 'S') return 0;
  if (s[0] == 'M') return 1;
  if (s[0] == 'L') return 2;
  if (s[0] == 'X') {
    if (s[1] == 'L') return 3;
    if (s[1] == 'X') {
      if (s[2] == 'L')
        return 4;
      else
        return 5;
    }
  }
}
int solve() {
  long long sz[6];
  long long g[6] = {}, g2[6] = {};
  vector<pair<int, int> > v;
  int n;
  for (int i = 0; i < 6; ++i) cin >> sz[i];
  cin >> n;
  v.resize(n);
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    s += ',';
    char t[16];
    int j = 0;
    int a = -1, b = -1, c = 0;
    for (int k = 0; k < s.size(); ++k) {
      t[j++] = s[k];
      if (s[k] == ',') {
        if (c == 0)
          a = rome_number(t);
        else
          b = rome_number(t);
        ++c;
        j = 0;
      }
    }
    v[i] = make_pair(a, b);
  }
  vector<int> ans(n, -1);
  for (int h = 0; h < 6; ++h) {
    int S_0 = 0, S_1 = 0;
    for (int i = 0; i < n; ++i) {
      if (v[i].first == h) {
        if (v[i].second == h + 1)
          S_1++;
        else
          S_0++;
      }
    }
    if (S_0 > sz[h]) {
      puts("NO");
      return 0;
    }
    if (S_0 + S_1 > sz[h]) S_1 = sz[h] - S_0;
    for (int i = 0; i < n; ++i) {
      if (v[i].first == h) {
        if (v[i].second == h + 1) {
          if (S_1 > 0) {
            ans[i] = h;
            v[i].first = -1;
            v[i].second = -1;
            --S_1;
          } else {
            v[i].first = h + 1;
            v[i].second = -1;
          }
        } else {
          v[i].first = -1;
          ans[i] = h;
          S_0--;
        }
      }
    }
  }
  printf("YES\n");
  for (int i = 0; i < n; ++i) {
    typedef char const* pchar;
    const pchar ROME[6] = {"S", "M", "L", "XL", "XXL", "XXXL"};
    printf("%s\n", ROME[ans[i]]);
  }
  return 0;
}
int main() { solve(); }
