#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b % 2) {
      res = (res * a) % 1000000007;
    }
    b /= 2;
    a = (a * a) % 1000000007;
  }
  return res;
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
string arr[] = {"S", "M", "L", "XL", "XXL", "XXXL"};
map<string, long long> mapp;
map<long long, string> revmap;
long long cnt[10];
string ans[100005];
vector<pair<long long, long long> > one, two;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (long long i = 0; i < 6; ++i) {
    cin >> cnt[i];
    mapp[arr[i]] = i;
    revmap[i] = arr[i];
  }
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    string choices;
    cin >> choices;
    string temp = "";
    long long in = -1;
    for (long long j = 0; j < choices.size(); ++j) {
      if (choices[j] == ',') {
        in = j;
        break;
      }
    }
    if (in == -1) {
      one.push_back({mapp[choices], i});
    } else {
      long long choice1, choice2;
      for (long long j = 0; j < in; ++j) {
        temp += choices[j];
      }
      choice1 = mapp[temp];
      temp = "";
      for (long long j = in + 1; j < choices.size(); ++j) {
        temp += choices[j];
      }
      choice2 = mapp[temp];
      two.push_back({min(choice1, choice2), i});
    }
  }
  for (auto& elem : one) {
    if (cnt[elem.first] > 0) {
      cnt[elem.first] -= 1;
      ans[elem.second] = revmap[elem.first];
    } else {
      cout << "NO\n";
      return 0;
    }
  }
  sort((two).begin(), (two).end());
  for (auto& elem : two) {
    if (cnt[elem.first] > 0) {
      cnt[elem.first] -= 1;
      ans[elem.second] = revmap[elem.first];
    } else if (cnt[elem.first + 1] > 0) {
      cnt[elem.first + 1] -= 1;
      ans[elem.second] = revmap[elem.first + 1];
    } else {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  for (long long i = 1; i <= n; ++i) {
    cout << ans[i] << '\n';
  }
  return 0;
}
