#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pci = pair<char, int>;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
const ll infll = 1e18 + 3;
const int maxn = 1e6 + 77;
const int nmax = 1e6 + 577;
const ll basell = 1e18 + 3;
const int mod = 1e9 + 7;
const ld eps = 1e-7;
const int inf = 1009000999;
const int nv = 100505;
const int baseint = 1000200013;
const ld PI = acos(-1.0);
inline bool EQ(ld a, ld b) { return fabs(a - b) < 1e-9; }
int s[10];
int ans[nv];
int inline solve() {
  ios::sync_with_stdio(NULL), cin.tie(NULL), cout.tie(NULL);
  ;
  cin >> s[0] >> s[1] >> s[2] >> s[3] >> s[4] >> s[5];
  int n;
  cin >> n;
  vector<pair<pii, int>> v;
  for (int i = 0; i < n; ++i) {
    string str;
    cin >> str;
    int h = -1;
    for (int j = 0; j < ((int)(str).size()); ++j) {
      if (str[j] == ',') h = j;
    }
    if (h == -1) {
      if (str == "S") s[0]--, ans[i] = 0;
      if (str == "M") s[1]--, ans[i] = 1;
      if (str == "L") s[2]--, ans[i] = 2;
      if (str == "XL") s[3]--, ans[i] = 3;
      if (str == "XXL") s[4]--, ans[i] = 4;
      if (str == "XXXL") s[5]--, ans[i] = 5;
    } else {
      pii g;
      if (str.substr(0, h) == "S") g.first = 0, g.second = 1;
      if (str.substr(0, h) == "M") g.first = 1, g.second = 2;
      if (str.substr(0, h) == "L") g.first = 2, g.second = 3;
      if (str.substr(0, h) == "XL") g.first = 3, g.second = 4;
      if (str.substr(0, h) == "XXL") g.first = 4, g.second = 5;
      v.push_back(make_pair(g, i));
    }
  }
  if (s[0] < 0 || s[1] < 0 || s[2] < 0 || s[3] < 0 || s[4] < 0 || s[5] < 0) {
    return cout << "NO", 0;
  }
  sort(begin(v), end(v));
  for (int i = 0; i < ((int)(v).size()); ++i) {
    if (s[v[i].first.first] > 0) {
      s[v[i].first.first]--;
      ans[v[i].second] = v[i].first.first;
    } else if (s[v[i].first.second] > 0) {
      s[v[i].first.second]--;
      ans[v[i].second] = v[i].first.second;
    } else {
      return cout << "NO", 0;
    }
  }
  cout << "YES\n";
  for (int i = 0; i < n; ++i) {
    if (ans[i] == 0) cout << "S\n";
    if (ans[i] == 1) cout << "M\n";
    if (ans[i] == 2) cout << "L\n";
    if (ans[i] == 3) cout << "XL\n";
    if (ans[i] == 4) cout << "XXL\n";
    if (ans[i] == 5) cout << "XXXL\n";
  }
  return 0;
}
int32_t main() {
  solve();
  return 0;
}
