#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 123;
const long long INF = (long long)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;
int type(string a) {
  if (a == "S") return 1;
  if (a == "M") return 2;
  if (a == "L") return 3;
  if (a == "XL") return 4;
  if (a == "XXL") return 5;
  if (a == "XXXL") return 6;
  return 7;
}
int a[10], n;
string t, name[10] = {"", "S", "M", "L", "XL", "XXL", "XXXL"}, res[N];
set<int> st[10];
vector<pair<int, pair<int, int> > > g;
int main() {
  for (int i = 1; i <= 6; i++) cin >> a[i];
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> t;
    string tmp1 = "", tmp2 = "";
    int pos = (int)(t.size());
    for (int j = 0; j < (int)(t.size()); j++) {
      if (t[j] == ',') {
        pos = j + 1;
        break;
      }
      tmp1 += t[j];
    }
    for (int j = pos; j < (int)(t.size()); j++) tmp2 += t[j];
    if (type(tmp2) < type(tmp1)) swap(tmp1, tmp2);
    if (type(tmp2) == 7) {
      res[i] = tmp1, a[type(tmp1)]--;
      continue;
    }
    g.push_back(make_pair(type(tmp1), make_pair(type(tmp2), i)));
  }
  sort(g.begin(), g.end());
  for (auto i : g) {
    if (a[i.first] > 0)
      a[i.first]--, res[i.second.second] = name[i.first];
    else
      a[i.second.first]--, res[i.second.second] = name[i.second.first];
  }
  for (int i = 1; i <= 6; i++)
    if (a[i] < 0) {
      puts("NO");
      return 0;
    }
  puts("YES");
  for (int i = 1; i <= n; i++) cout << res[i] << "\n";
  return 0;
}
