#include <bits/stdc++.h>
using namespace std;
const int N = 100500;
int r[6];
map<string, int> c;
map<int, string> cc;
bool vis[N];
vector<pair<int, int> > w[6];
int ans[N];
int main() {
  c["S"] = 0;
  c["M"] = 1;
  c["L"] = 2;
  c["XL"] = 3;
  c["XXL"] = 4;
  c["XXXL"] = 5;
  cc[0] = "S";
  cc[1] = "M";
  cc[2] = "L";
  cc[3] = "XL";
  cc[4] = "XXL";
  cc[5] = "XXXL";
  for (int i = 0, ttto = 6; i < ttto; i++) cin >> r[i];
  int n, f = 1;
  cin >> n;
  for (int i = 0, ttto = n; i < ttto; i++) {
    string s, t;
    cin >> s;
    int p = s.find(",");
    if (p != string::npos) t = s.substr(p + 1, s.size());
    if (p == string::npos) {
      r[c[s]]--;
      vis[i] = 1;
      ans[i] = c[s];
      if (r[c[s]] < 0) f = 0;
    } else {
      s = s.substr(0, p);
      int u = c[s], v = c[t];
      if (u > v) swap(u, v);
      w[u].push_back(pair<int, int>(1, i));
      w[v].push_back(pair<int, int>(0, i));
    }
  }
  if (f == 0)
    puts("NO");
  else {
    for (int i = 0, ttto = 6; i < ttto; i++) {
      sort(w[i].begin(), w[i].end());
      for (int j = 0, ttto = w[i].size(); j < ttto; j++)
        if (!vis[w[i][j].second] && r[i])
          ans[w[i][j].second] = i, vis[w[i][j].second] = 1, r[i]--;
    }
    for (int i = 0, ttto = n; i < ttto; i++)
      if (!vis[i]) {
        cerr << i << endl;
        puts("NO");
        return 0;
      }
    puts("YES");
    for (int i = 0, ttto = n; i < ttto; i++) cout << cc[ans[i]] << "\n";
  }
}
