#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 100;
const long long LINF = 1e18 + 228;
const double DINF = 5e18 + .0;
const int ITER = 300;
const double EPS = 1e-6;
const int MOD = 1000000007;
const long long MAXN = 1e5 + 10;
int cnt[6];
string ans[MAXN];
bool was[MAXN];
pair<string, string> can[MAXN];
int n;
void solve() {
  map<string, int> tosz;
  tosz["S"] = 0;
  tosz["M"] = 1;
  tosz["L"] = 2;
  tosz["XL"] = 3;
  tosz["XXL"] = 4;
  tosz["XXXL"] = 5;
  for (int i = 0; i < 6; ++i) cin >> cnt[i];
  cin >> n;
  for (int i = 0; i < n; ++i) {
    string in;
    cin >> in;
    bool df = false;
    string left = "", right = "";
    for (int i = 0; i < (int)in.length(); ++i) {
      if (in[i] == ',') {
        df = true;
        continue;
      }
      if (!df)
        left += in[i];
      else
        right += in[i];
    }
    if (!df) right = "tao";
    can[i] = make_pair(left, right);
  }
  for (int i = 0; i < n; ++i) {
    if (can[i].second == "tao") {
      if (!cnt[tosz[can[i].first]]) {
        cout << "NO";
        return;
      }
      --cnt[tosz[can[i].first]];
      ans[i] = can[i].first;
      was[i] = true;
    }
  }
  for (int cur = 0; cur < 5; ++cur) {
    for (int i = 0; i < n; ++i) {
      if (was[i]) continue;
      if (tosz[can[i].first] == cur) {
        if (cnt[cur]) {
          ans[i] = can[i].first;
          was[i] = true;
          --cnt[cur];
        } else if (cnt[cur + 1]) {
          was[i] = true;
          ans[i] = can[i].second;
          --cnt[cur + 1];
        } else {
          cout << "NO";
          return;
        }
      }
    }
  }
  cout << "YES\n";
  for (int i = 0; i < n; ++i) cout << ans[i] << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
}
