#include <bits/stdc++.h>
using namespace std;
int mod = 1e9 + 7;
long long powmod(long long a, long long b) {
  long long res = 1;
  if (a >= mod) a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a;
    if (res >= mod) res %= mod;
    a = a * a;
    if (a >= mod) a %= mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
int lef[17], sum[17];
int sing[17], com[17];
int t[17][17];
int x[100000 + 5], y[100000 + 5];
string ss[10] = {"S", "M", "L", "XL", "XXL", "XXXL"};
void p(int x) { cout << ss[x - 1] << '\n'; }
int main() {
  ios_base::sync_with_stdio(false);
  ;
  cin.tie(0);
  cout.tie(0);
  string s;
  int i, j, n, typ;
  for (i = 1; i <= 6; i++) {
    cin >> lef[i];
  }
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> s;
    for (j = 0; j < s.length(); j++) {
      if (s[j] == ',') break;
    }
    if (s[0] == 'S')
      typ = 1;
    else if (s[0] == 'M')
      typ = 2;
    else if (s[0] == 'L')
      typ = 3;
    else if (s[1] == 'L')
      typ = 4;
    else if (s[2] == 'L')
      typ = 5;
    else if (s[3] == 'L')
      typ = 6;
    if (j == s.length()) {
      sing[typ]++;
      x[i] = 1;
      y[i] = typ;
    } else {
      com[typ]++;
      x[i] = 2;
      y[i] = typ;
    }
  }
  i = 1;
  while (i < 7) {
    if ((i > 1) && com[i - 1]) {
      lef[i] -= com[i - 1];
      t[i][i - 1] += com[i - 1];
      com[i - 1] = 0;
      if (lef[i] < 0) {
        cout << "NO\n";
        return 0;
      }
    }
    lef[i] -= sing[i];
    if (lef[i] < 0) {
      cout << "NO\n";
      return 0;
    }
    int v = min(lef[i], com[i]);
    t[i][i + 1] += min(lef[i], com[i]);
    lef[i] -= min(lef[i], com[i]);
    com[i] -= v;
    i++;
  }
  cout << "YES\n";
  for (i = 1; i <= n; i++) {
    if (x[i] == 1)
      p(y[i]);
    else if (t[y[i]][y[i] + 1]) {
      t[y[i]][y[i] + 1]--;
      p(y[i]);
    } else {
      t[y[i] + 1][y[i]]--;
      p(y[i] + 1);
    }
  }
  return 0;
}
