#include <bits/stdc++.h>
using namespace std;
const char* szt[] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int szs[6];
struct one {
  int num;
  int s1;
};
struct dbl {
  int num;
  int s1, s2;
  int sel;
  friend bool operator<(const dbl& l, const dbl& r) {
    if (l.s1 == r.s1) {
      return l.s2 < r.s2;
    }
    return l.s1 < r.s1;
  }
};
struct n_cmp {
  bool operator()(const dbl& l, const dbl& r) { return l.num < r.num; }
};
int sz_to_sz(const string& s) {
  int r;
  if (s == "S") {
    r = 0;
  } else if (s == "M") {
    r = 1;
  } else if (s == "L") {
    r = 2;
  } else if (s == "XL") {
    r = 3;
  } else if (s == "XXL") {
    r = 4;
  } else if (s == "XXXL") {
    r = 5;
  }
  return r;
}
bool is_valid() {
  for (int i = 0; i < 6; i++) {
    if (szs[i] < 0) {
      return false;
    }
  }
  return true;
}
int main() {
  for (int i = 0; i < 6; i++) {
    cin >> szs[i];
  }
  int n;
  cin >> n;
  vector<one> ones;
  vector<dbl> dbls;
  for (int i = 0; i < n; i++) {
    string str;
    cin >> str;
    auto r = str.find(",");
    if (r == -1) {
      one o;
      o.num = i + 1;
      o.s1 = sz_to_sz(str);
      ones.push_back(o);
    } else {
      dbl d;
      d.num = i + 1;
      d.s1 = sz_to_sz(str.substr(0, r));
      d.s2 = sz_to_sz(str.substr(r + 1, str.size() - r - 1));
      dbls.push_back(d);
    }
  }
  for (int i = 0; i < ones.size(); i++) {
    szs[ones[i].s1]--;
  }
  sort(dbls.begin(), dbls.end());
  if (!is_valid()) {
    cout << "NO";
    return 0;
  }
  for (int i = 0; i < dbls.size(); i++) {
    if (szs[dbls[i].s1] > 0) {
      szs[dbls[i].s1]--;
      dbls[i].sel = dbls[i].s1;
    } else {
      szs[dbls[i].s2]--;
      dbls[i].sel = dbls[i].s2;
    }
  }
  if (!is_valid()) {
    cout << "NO";
    return 0;
  }
  n_cmp tmp;
  sort(dbls.begin(), dbls.end(), tmp);
  cout << "YES" << endl;
  int i = 0, j = 0;
  while (i < ones.size() && j < dbls.size()) {
    if (ones[i].num < dbls[j].num) {
      cout << szt[ones[i].s1] << endl;
      i++;
    } else {
      cout << szt[dbls[j].sel] << endl;
      j++;
    }
  }
  for (; i < ones.size(); i++) {
    cout << szt[ones[i].s1] << endl;
  }
  for (; j < dbls.size(); j++) {
    cout << szt[dbls[j].sel] << endl;
  }
  return 0;
}
