#include <bits/stdc++.h>
using namespace std;
int check(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;
  else
    return 5;
}
string check1(int s) {
  if (s == 0) return "S";
  if (s == 1) return "M";
  if (s == 2) return "L";
  if (s == 3) return "XL";
  if (s == 4)
    return "XXL";
  else
    return "XXXL";
}
int i, n, t[6], l, k, j;
string s, str[2], ans[100005];
vector<pair<int, int> > v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  for (i = 0; i < 6; i++) cin >> t[i];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s;
    l = s.length();
    k = 0;
    str[0] = "";
    for (j = 0; j < l; j++) {
      if (s[j] == ',') {
        k++;
        break;
      }
      str[k] += s[j];
    }
    if (k == 0) {
      t[check(str[0])]--;
      if (t[check(str[0])] < 0) {
        cout << "NO\n";
        return 0;
      }
      ans[i] = str[0];
    } else {
      v.push_back(make_pair(check(str[0]), i));
    }
  }
  sort(v.begin(), v.end());
  for (i = 0; i < v.size(); i++) {
    if (t[v[i].first] > 0) {
      t[v[i].first]--;
      ans[v[i].second] = check1(v[i].first);
    } else {
      t[v[i].first + 1]--;
      if (t[v[i].first + 1] < 0) {
        cout << "NO\n";
        return 0;
      }
      ans[v[i].second] = check1(v[i].first + 1);
    }
  }
  cout << "YES\n";
  for (i = 0; i < n; i++) cout << ans[i] << "\n";
  return 0;
}
