#include <bits/stdc++.h>
using namespace std;
int ans[100001];
int prefer[100001];
vector<int> v[6];
string data[] = {"S", "M", "L", "XL", "XXL", "XXXL"};
bool cmp(int x, int y) { return prefer[x] < prefer[y]; }
int which(string x) {
  for (int i = 0; i < 6; i++) {
    if (x == data[i]) return i;
  }
}
int main() {
  int a[6];
  for (int i = 0; i < 6; i++) {
    cin >> a[i];
  }
  int n;
  cin >> n;
  memset(ans, -1, sizeof ans);
  string s;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s.find(',') == string::npos) {
      int x = which(s);
      if (a[x] < 1) {
        cout << "NO\n";
        return 0;
      }
      ans[i] = x;
      a[x]--;
    } else {
      int a = which(s.substr(0, s.find(',')));
      int b = which(s.substr(s.find(',') + 1));
      v[a].push_back(i);
      v[b].push_back(i);
      prefer[i] = min(a, b);
    }
  }
  for (int i = 0; i < 6; i++) {
    sort(v[i].begin(), v[i].end(), cmp);
    for (auto z : v[i]) {
      if (ans[z] == -1 && a[i] > 0) {
        a[i]--;
        ans[z] = i;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (ans[i] == -1) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES\n";
  for (int i = 0; i < n; i++) {
    cout << data[ans[i]] << "\n";
  }
  return 0;
}
