#include <bits/stdc++.h>
using namespace std;
class cmp {
 public:
  bool operator()(pair<int, int> a, pair<int, int> b) {
    return a.first < b.first;
  }
};
int main() {
  unordered_map<string, int> sh;
  sh["S"] = 0;
  sh["M"] = 1;
  sh["L"] = 2;
  sh["XL"] = 3;
  sh["XXL"] = 4;
  sh["XXXL"] = 5;
  char* strs[] = {"S", "M", "L", "XL", "XXL", "XXXL"};
  int cnt[6];
  for (int i = 0; i < 6; ++i) {
    scanf("%d", &cnt[i]);
  }
  int n;
  scanf("%d", &n);
  vector<pair<int, int> > inter;
  int res[n];
  for (int i = 0; i < n; ++i) {
    char s[40];
    scanf("%s", s);
    string str(s);
    int dot = -1;
    for (int j = 0; j < str.size(); ++j) {
      if (str[j] == ',') {
        dot = j;
        break;
      }
    }
    if (dot == -1) {
      int shirt = sh[str];
      if (cnt[shirt] == 0) {
        printf("NO");
        return 0;
      }
      cnt[shirt]--;
      res[i] = shirt;
    } else {
      string sh1 = string(str.begin(), str.begin() + dot);
      string sh2 = string(str.begin() + dot + 1, str.end());
      inter.push_back(make_pair(min(sh[sh1], sh[sh2]), i));
    }
  }
  sort(inter.begin(), inter.end(), cmp());
  for (int i = 0; i < inter.size(); ++i) {
    int shirt = inter[i].first;
    if (cnt[shirt] > 0) {
      cnt[shirt]--;
      res[inter[i].second] = shirt;
    } else if (cnt[shirt + 1] > 0) {
      cnt[shirt + 1]--;
      res[inter[i].second] = shirt + 1;
    } else {
      printf("NO");
      return 0;
    }
  }
  printf("YES\n");
  for (int i = 0; i < n; ++i) {
    printf("%s\n", strs[res[i]]);
  }
  return 0;
}
