#include <bits/stdc++.h>
using namespace std;
long long int mulmod(long long int a, long long int b, long long int m) {
  long long int q =
      (long long int)(((long double)a * (long double)b) / (long double)m);
  long long int r = a * b - q * m;
  if (r > m) r %= m;
  if (r < 0) r += m;
  return r;
}
template <typename T>
T MOD(T a, T b) {
  return (a < b ? a : a % b);
}
template <typename T>
T expo(T e, T n) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = x * p;
    p = p * p;
    n >>= 1;
  }
  return x;
}
template <typename T>
T power(T e, T n, T m) {
  T x = 1, p = e;
  while (n) {
    if (n & 1) x = mulmod(x, p, m);
    p = mulmod(p, p, m);
    n >>= 1;
  }
  return x;
}
template <typename T>
T gcd(T a, T b) {
  if (a % b) return gcd(b, a % b);
  return b;
}
template <typename T>
T lcm(T a, T b) {
  return (a * (b / gcd(a, b)));
}
map<string, int> m;
map<int, string> p;
int a[7];
vector<pair<int, pair<int, int> > > need;
string ans[100005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  for (int i = 1; i <= 6; i++) {
    cin >> a[i];
  }
  m["S"] = 1, m["M"] = 2, m["L"] = 3, m["XL"] = 4, m["XXL"] = 5, m["XXXL"] = 6;
  for (auto &x : m) p[x.second] = x.first;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s;
    cin >> s;
    string x, y;
    bool is = false;
    for (char c : s) {
      if (c == ',') {
        is = true;
        continue;
      }
      (is ? y : x) += c;
    }
    if (y == "") {
      if (a[m[x]]) {
        --a[m[x]];
        ans[i] = x;
      } else {
        cout << "NO";
        return 0;
      }
    } else {
      if (m[x] > m[y]) swap(x, y);
      need.push_back({m[x], {m[y], i}});
    }
  }
  sort(need.begin(), need.end());
  for (pair<int, pair<int, int> > x : need) {
    if (a[x.first]) {
      --a[x.first];
      ans[x.second.second] = p[x.first];
    } else if (a[x.second.first]) {
      --a[x.second.first];
      ans[x.second.second] = p[x.second.first];
    } else {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES\n";
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << "\n";
  }
  return 0;
}
