#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100030;
const long long MODD = 1000000009;
int A[6];
int ans[MAX_N];
vector<int> v[MAX_N];
string s[6] = {"S", "M", "L", "XL", "XXL", "XXXL"};
void do_case() {
  for (int i = 0; i < 6; i++) cin >> A[i];
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) ans[i] = -1;
  for (int i = 0; i < n; i++) {
    string t;
    cin >> t;
    if (t.find(',') == string::npos) {
      int size = find(s, s + 6, t) - s;
      A[size]--;
      ans[i] = size;
      if (A[size] < 0) {
        cout << "NO" << endl;
        return;
      }
    } else {
      for (int ii = 0; ii < 2; ii++) {
        string p = t.substr(0, t.find(','));
        v[i].push_back(find(s, s + 6, p) - s);
        t = t.substr(t.find(',') + 1);
      }
      if (v[i][0] > v[i][1]) swap(v[i][0], v[i][1]);
    }
  }
  for (int k = 0; k < 3; k++) {
    for (int i = 0; i < n; i++) {
      if (ans[i] != -1) continue;
      for (int z = 0; z < 2; z++) {
        if (v[i][z] == k) {
          if (A[k] == 0 && A[v[i][1 - z]] == 0) {
            cout << "NO" << endl;
            return;
          }
          ans[i] = (A[k] ? k : v[i][1 - z]);
          A[ans[i]]--;
          break;
        }
        if (v[i][z] == 5 - k) {
          if (A[5 - k] == 0 && A[v[i][1 - z]] == 0) {
            cout << "NO" << endl;
            return;
          }
          ans[i] = (A[5 - k] ? 5 - k : v[i][1 - z]);
          A[ans[i]]--;
          break;
        }
      }
    }
  }
  for (int i = 0; i < n; i++)
    if (ans[i] == -1) {
      cout << "NO" << endl;
      return;
    }
  cout << "YES" << endl;
  for (int i = 0; i < n; i++) cout << s[ans[i]] << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  do_case();
  return 0;
}
