#include <bits/stdc++.h>
using namespace std;
template <typename T>
T next_int() {
  T x = 0, p = 1;
  char ch;
  do {
    ch = getchar();
  } while (ch <= ' ');
  if (ch == '-') {
    p = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  return p * x;
}
string next_token() {
  char ch;
  string ans = "";
  do {
    ch = getchar();
  } while (ch <= ' ');
  while (ch > ' ') {
    ans += ch;
    ch = getchar();
  }
  return ans;
}
const long long INF = (long long)1e18;
const int INFINT = (int)1e9 + 227 + 1;
const int MAXN = (int)1e5 + 227 + 1;
const int MOD = (int)1e9 + 7;
const long double EPS = 1e-7;
long long bin_pow(long long a, long long b) {
  if (!b) return 1;
  long long ans = bin_pow(a, b / 2);
  ans = ans * ans;
  if (b % 2) ans = ans * a;
  return ans;
}
const string type[6] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int a[6];
int f(string a) {
  for (int i = 0; i < 6; i++)
    if (type[i] == a) return i;
  assert(0);
}
bool used[MAXN];
vector<pair<int, int> > c[6];
int main() {
  for (int i = 0; i < 6; i++) cin >> a[i];
  int n = next_int<int>();
  vector<string> ans(n, "-1");
  for (int i = 0; i < n; i++) {
    string A;
    cin >> A;
    int p = -1;
    for (int j = 0; j < A.size(); j++) {
      if (A[j] == ',') p = j;
    }
    if (p == -1) {
      ans[i] = A;
      a[f(A)]--;
    } else {
      int fi = f(A.substr(0, p));
      int se = f(A.substr(p + 1, (A.size() - (p + 1))));
      c[fi].push_back(make_pair(0, i));
      c[se].push_back(make_pair(-1, i));
    }
  }
  for (int i = 0; i < 6; i++) {
    sort((c[i]).begin(), (c[i]).end());
    for (int j = 0; j < c[i].size() && a[i] > 0; j++) {
      if (used[c[i][j].second]) continue;
      ans[c[i][j].second] = type[i];
      used[c[i][j].second] = 1;
      a[i]--;
    }
  }
  bool ok = 1;
  for (int i = 0; i < n; i++) ok &= (ans[i] != "-1");
  for (int i = 0; i < 6; i++) ok &= (a[i] >= 0);
  if (!ok) {
    puts("NO");
    return 0;
  }
  puts("YES");
  for (int i = 0; i < n; i++) cout << ans[i] << "\n";
}
