#include <bits/stdc++.h>
using namespace std;
int a[100005];
int ans[100005];
string s[100005];
map<string, int> h;
vector<pair<int, int> > v;
string res[6] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int main() {
  memset(ans, -1, sizeof(ans));
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  h["S"] = 0;
  h["M"] = 1;
  h["L"] = 2;
  h["XL"] = 3;
  h["XXL"] = 4;
  h["XXXL"] = 5;
  for (int i = 0; i < 6; i++) cin >> a[i];
  int n;
  cin >> n;
  bool ok = 1;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    string t[2];
    t[0] = "";
    t[1] = "";
    int k = 0;
    int m = s[i].length();
    for (int j = 0; j < m; j++) {
      if (s[i][j] == ',')
        k++;
      else
        t[k] += s[i][j];
    }
    if (t[1] == "") {
      ans[i] = h[t[0]];
      a[h[t[0]]]--;
      if (a[h[t[0]]] < 0) ok = 0;
    } else
      v.push_back(pair<int, int>(h[t[0]], i));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); i++) {
    int j = v[i].second, x = v[i].first;
    if (a[x] > 0)
      ans[j] = x, a[x]--;
    else
      ans[j] = x + 1, a[x + 1]--;
  }
  for (int i = 0; i < 6; i++)
    if (a[i] < 0) ok = 0;
  if (!ok)
    printf("NO\n");
  else {
    cout << "YES"
         << "\n";
    for (int i = 1; i <= n; i++) cout << res[ans[i]] << "\n";
  }
}
