#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename... T>
void rd(T&... args) {
  ((cin >> args), ...);
}
template <typename... T>
void wr(T... args) {
  ((cout << args << " "), ...);
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a[6];
  for (int i = 0; i < 6; i++) {
    cin >> a[i];
  }
  map<string, int> sti{{"S", 0},  {"M", 1},   {"L", 2},
                       {"XL", 3}, {"XXL", 4}, {"XXXL", 5}};
  int n;
  cin >> n;
  vector<vector<int>> b(6);
  vector<int> ans(n);
  for (int i = 0; i < n; i++) {
    vector<string> sz;
    string s;
    cin >> s;
    string t;
    for (auto c : s) {
      if (c == ',') {
        sz.push_back(t);
        t = "";
      } else
        t += c;
    }
    sz.push_back(t);
    if (sz.size() == 1) {
      a[sti[sz[0]]]--;
      ans[i] = sti[sz[0]];
    } else
      b[sti[sz[0]]].push_back(i);
  }
  for (int i = 0; i < 6; i++) {
    if (a[i] < 0)
      return cout << "NO\n", 0;
    else {
      int x = min<int>(a[i], b[i].size());
      for (int j = 0; j < x; j++) ans[b[i][j]] = i;
      for (int j = x; j < (int)b[i].size(); j++) {
        ans[b[i][j]] = i + 1;
        a[i + 1]--;
      }
    }
  }
  cout << "YES\n";
  for (auto x : ans) {
    for (auto [s, v] : sti) {
      if (v == x) {
        cout << s << '\n';
        break;
      }
    }
  }
  return 0;
}
