#include <bits/stdc++.h>
using namespace std;
template <typename T>
using min_queue = priority_queue<T, vector<T>, greater<T>>;
const long long MOD = 1e9 + 7;
int N;
int cnt[6];
int res[100100];
vector<int> v[6];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  const vector<string> sizes = {"S", "M", "L", "XL", "XXL", "XXXL"};
  map<string, int> inv;
  {
    int k = 0;
    for (auto s : sizes) inv[s] = k++;
  }
  for (int i = 0; i < 6; i++) {
    cin >> cnt[i];
  }
  cin >> N;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    string t;
    for (char c : s) {
      if (c == ',') break;
      t += c;
    }
    int k = inv[t];
    if (s == t) {
      cnt[k]--;
      res[i] = k;
    } else {
      v[k].push_back(i);
    }
  }
  bool good = 1;
  for (int i = 0; i < 5; i++) {
    if (cnt[i] < 0) {
      good = 0;
      break;
    }
    while (!v[i].empty() && cnt[i] > 0) {
      cnt[i]--;
      res[v[i].back()] = i;
      v[i].pop_back();
    }
    while (!v[i].empty() && cnt[i + 1] > 0) {
      cnt[i + 1]--;
      res[v[i].back()] = i + 1;
      v[i].pop_back();
    }
    if (!v[i].empty() || cnt[i + 1] < 0) {
      good = 0;
      break;
    }
  }
  if (!good) {
    cout << "NO\n";
    return 0;
  }
  cout << "YES\n";
  for (int i = 0; i < N; i++) cout << sizes[res[i]] << '\n';
  return 0;
}
