#include <bits/stdc++.h>
using namespace std;
const int INFint = 2e9;
const long long INF = 2e18;
const int MOD = 1e9 + 7;
vector<vector<pair<int, int> > > g;
vector<int> used;
int get(string s) {
  if (s == "S") return 0;
  if (s == "M") return 1;
  if (s == "L") return 2;
  if (s == "XL") return 3;
  if (s == "XXL") return 4;
  return 5;
}
string back(int x) {
  if (x == 0) return "S";
  if (x == 1) return "M";
  if (x == 2) return "L";
  if (x == 3) return "XL";
  if (x == 4) return "XXL";
  return "XXXL";
}
void bad() {
  cout << "NO";
  exit(0);
}
int main() {
  ios_base::sync_with_stdio(0);
  int n = 6;
  vector<int> cnt(n);
  for (auto &x : cnt) cin >> x;
  g.resize(n);
  int k;
  cin >> k;
  vector<string> ans(k, "kek");
  for (int i = 0; i < k; i++) {
    string s;
    cin >> s;
    if (s.find(',') != -1) {
      int a = get(s.substr(0, s.find(',')));
      int b = get(s.substr(s.find(',') + 1));
      g[a].push_back({0, i});
      g[b].push_back({1, i});
    } else {
      int cur = get(s);
      cnt[cur]--;
      if (cnt[cur] < 0) bad();
      ans[i] = s;
    }
  }
  for (int c = 5; c > -1; c--) {
    if (!cnt[c]) continue;
    sort(g[c].begin(), g[c].end());
    for (auto cur : g[c]) {
      int to = cur.second;
      if (!cnt[c]) break;
      if (ans[to] != "kek") continue;
      ans[to] = back(c);
      cnt[c]--;
    }
  }
  for (auto x : ans) {
    if (x == "kek") bad();
  }
  cout << "YES\n";
  for (auto x : ans) cout << x << endl;
  fprintf(stderr, "\nTIME = %lf\n", 1.0 * clock() / CLOCKS_PER_SEC);
  ;
  return 0;
}
