#include <bits/stdc++.h>
using namespace std;
vector<int> v[100001];
int give(string s) {
  if (s == "S") return 0;
  if (s == "M") return 1;
  if (s == "L") return 2;
  if (s == "XL") return 3;
  if (s == "XXL") return 4;
  if (s == "XXXL") return 5;
}
int a[6];
int main() {
  int N, i, j;
  for (i = 0; i < 6; i++) cin >> a[i];
  cin >> N;
  int c = 1;
  for (j = 1; j <= N; j++) {
    string s;
    cin >> s;
    string t;
    for (i = 0; i < s.length(); i++) {
      if (s[i] != ',')
        t.push_back(s[i]);
      else {
        v[c].push_back(give(t));
        t.clear();
      }
    }
    v[c].push_back(give(t));
    c++;
  }
  for (i = 0; i < 6; i++) {
    for (j = 1; j <= N; j++) {
      if (v[j][0] == i && v[j].size() == 1) a[i]--;
    }
    if (a[i] < 0) {
      cout << "NO\n";
      return 0;
    }
    for (j = 1; j <= N && a[i] > 0; j++) {
      if (v[j][0] == i && v[j].size() == 2) {
        v[j].pop_back();
        a[i]--;
      }
    }
    for (j = 1; j <= N; j++) {
      if (v[j][0] == i && v[j].size() == 2) {
        v[j][0] = v[j][1];
        v[j].pop_back();
      }
    }
  }
  cout << "YES\n";
  for (i = 1; i <= N; i++) {
    switch (v[i][0]) {
      case 0:
        cout << "S\n";
        break;
      case 1:
        cout << "M\n";
        break;
      case 2:
        cout << "L\n";
        break;
      case 3:
        cout << "XL\n";
        break;
      case 4:
        cout << "XXL\n";
        break;
      case 5:
        cout << "XXXL\n";
    }
  }
  return 0;
}
