#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e5 + 5, mod = (int)1e9 + 7;
string tshirt[] = {"S", "M", "L", "XL", "XXL", "XXXL"};
vector<int> lis[10];
int sz[10];
int avail[10];
string ans[maxn];
bool is[maxn];
int find(string arg) {
  int ind;
  for (ind = 0; ind < 6; ind++)
    if (arg == tshirt[ind]) break;
  return ind;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m, i, j, k, l, u, v;
  for (i = 0; i < 6; i++) cin >> avail[i];
  cin >> n;
  for (i = 1; i <= n; i++) {
    string t;
    cin >> t;
    for (j = 0; j < t.length(); j++)
      if (t[j] == ',') break;
    if (j < t.length()) {
      is[i] = 1;
      string smll = "";
      for (k = 0; k < j; k++) smll += t[k];
      u = find(smll);
      lis[u].emplace_back(i);
      sz[u]++;
    } else {
      u = find(t);
      if (avail[u])
        ans[i] = t;
      else {
        cout << "NO";
        return 0;
      }
      avail[u]--;
    }
  }
  for (i = 0; i < 5; i++) {
    for (auto it : lis[i]) {
      if (avail[i]) {
        avail[i]--;
        ans[it] = tshirt[i];
      } else if (avail[i + 1]) {
        avail[i + 1]--;
        ans[it] = tshirt[i + 1];
      } else {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES\n";
  for (i = 1; i <= n; i++) cout << ans[i] << endl;
  return 0;
}
