#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MOD = 1000000007;
int ans[100005];
int tot[6];
map<string, int> toInt;
vector<int> want[6];
string toStr[6];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  toInt["S"] = 0;
  toStr[0] = "S";
  toInt["M"] = 1;
  toStr[1] = "M";
  toInt["L"] = 2;
  toStr[2] = "L";
  toInt["XL"] = 3;
  toStr[3] = "XL";
  toInt["XXL"] = 4;
  toStr[4] = "XXL";
  toInt["XXXL"] = 5;
  toStr[5] = "XXXL";
  for (int i = (0); i < (6); i++) cin >> tot[i];
  int n;
  cin >> n;
  for (int i = (0); i < (n); i++) {
    string s;
    cin >> s;
    string a, b = "!";
    for (char c : s) {
      if (b != "!")
        b += c;
      else if (c == ',')
        b = "";
      else
        a += c;
    }
    if (b == "!") {
      ans[i] = toInt[a];
      tot[ans[i]]--;
    } else
      want[toInt[a]].push_back(i);
  }
  for (int i = (0); i < (6); i++) {
    if (tot[i] < 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  for (int i = (0); i < (6); i++) {
    for (int& v : want[i]) {
      if (tot[i]) {
        tot[i]--;
        ans[v] = i;
      } else {
        if (!tot[i + 1]) {
          cout << "NO" << endl;
          return 0;
        }
        tot[i + 1]--;
        ans[v] = i + 1;
      }
    }
  }
  cout << "YES" << endl;
  for (int i = (0); i < (n); i++) {
    cout << toStr[ans[i]] << endl;
  }
}
