#include <bits/stdc++.h>
using namespace std;
map<string, long long> ma;
long long a[100010][10], b[100], us[1000000];
string tr[100];
pair<long long, pair<long long, long long> > c[1000000];
int main() {
  long long n, i, j;
  ma["S"] = 1;
  ma["M"] = 2;
  ma["L"] = 3;
  ma["XL"] = 4;
  ma["XXL"] = 5;
  ma["XXXL"] = 6;
  tr[1] = "S";
  tr[2] = "M";
  tr[3] = "L";
  tr[4] = "XL";
  tr[5] = "XXL";
  tr[6] = "XXXL";
  long long kol = 0;
  for (i = 1; i <= 6; i++) cin >> b[i];
  cin >> n;
  string str = "", s;
  for (i = 1; i <= n; i++) {
    cin >> s;
    long long k = 0;
    str = "";
    for (j = 0; j < s.size(); j++) {
      if (s[j] == ',') {
        k++, a[i][k] = ma[str];
        str = "";
      } else
        str = str + s[j];
    }
    k++, a[i][k] = ma[str];
    if (k == 2) {
      kol++;
      c[kol].first = a[i][1];
      c[kol].second.first = a[i][2];
      c[kol].second.second = i;
    } else {
      us[i] = a[i][1];
      b[a[i][1]]--;
      if (b[a[i][1]] == -1) {
        cout << "NO";
        return 0;
      }
    }
  }
  sort(c + 1, c + 1 + kol);
  for (i = 1; i <= kol; i++) {
    if (b[c[i].first] != 0) {
      us[c[i].second.second] = c[i].first;
      b[c[i].first]--;
    } else {
      if (b[c[i].second.first] != 0)
        us[c[i].second.second] = c[i].second.first;
      else {
        cout << "NO";
        return 0;
      }
      b[c[i].second.first]--;
    }
  }
  cout << "YES\n";
  for (i = 1; i <= n; i++) {
    cout << tr[us[i]] << '\n';
  }
}
