#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const double PI = 3.14159265358979323846264338;
string s[5] = {"S,M", "M,L", "L,XL", "XL,XXL", "XXL,XXXL"};
string ss[6] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int cnt[6];
string p[500005];
int main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  for (int i = 0; i < 6; i++) cin >> cnt[i];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> p[i];
    for (int j = 0; j < 6; j++) {
      if (p[i] == ss[j]) {
        cnt[j]--;
        break;
      }
    }
  }
  for (int i = 0; i < 6; i++) {
    if (cnt[i] < 0) {
      cout << "NO"
           << "\n";
      return 0;
    }
  }
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < n; j++) {
      if (p[j] == s[i]) {
        if (cnt[i] > 0) {
          cnt[i]--;
          p[j] = ss[i];
        } else if (cnt[i + 1] > 0) {
          cnt[i + 1]--;
          p[j] = ss[i + 1];
        } else {
          cout << "NO"
               << "\n";
          return 0;
        }
      }
    }
  }
  cout << "YES"
       << "\n";
  for (int i = 0; i < n; i++) cout << p[i] << "\n";
  return 0;
}
