#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
bool cmp(const pair<string, int> &a, const pair<string, int> &b) {
  if (a.first.length() == b.first.length()) {
    return a.first > b.first;
  }
  return a.first < b.first;
}
int main(int argc, char *argv[]) {
  cin >> mp["S"] >> mp["M"] >> mp["L"] >> mp["XL"] >> mp["XXL"] >> mp["XXXL"];
  int n;
  cin >> n;
  string mas[n];
  vector<pair<string, int> > v;
  for (int i = 0; i < n; ++i) {
    string str;
    cin >> str;
    bool d = true;
    for (int j = 0; j < str.length(); ++j) {
      if (str[j] == ',') {
        d = false;
      }
    }
    if (d) {
      mp[str]--;
      mas[i] = str;
      if (mp[str] < 0) {
        cout << "NO";
        return 0;
      }
    } else {
      int j;
      string s_1, s_2;
      for (j = 0; str[j] != ','; ++j) {
        s_1 += str[j];
      }
      j++;
      for (; j < str.length(); ++j) {
        s_2 += str[j];
      }
      if (!mp[s_1] && !mp[s_2]) {
        cout << "NO";
        return 0;
      }
      if (!mp[s_1] && mp[s_2]) {
        mp[s_2]--;
        mas[i] = s_2;
      } else if (mp[s_1] && !mp[s_2]) {
        mp[s_1]--;
        mas[i] = s_1;
      } else if (mp[s_1] && mp[s_2]) {
        v.push_back(make_pair(s_1, i));
      }
    }
  }
  sort(v.begin(), v.end(), cmp);
  for (int i = 0; i < v.size(); ++i) {
    if (mp[v[i].first]) {
      mas[v[i].second] = v[i].first;
      mp[v[i].first]--;
    } else {
      if (v[i].first == "S") {
        mp["M"]--;
        mas[v[i].second] = "M";
        if (mp["M"] < 0) {
          cout << "NO";
          return 0;
        }
      } else if (v[i].first == "M") {
        mp["L"]--;
        mas[v[i].second] = "L";
        if (mp["L"] < 0) {
          cout << "NO";
          return 0;
        }
      } else if (v[i].first == "L") {
        mp["XL"]--;
        mas[v[i].second] = "XL";
        if (mp["XL"] < 0) {
          cout << "NO";
          return 0;
        }
      } else if (v[i].first == "XL") {
        mp["XXL"]--;
        mas[v[i].second] = "XXL";
        if (mp["XXL"] < 0) {
          cout << "NO";
          return 0;
        }
      } else if (v[i].first == "XXL") {
        mp["XXXL"]--;
        mas[v[i].second] = "XXXL";
        if (mp["XXXL"] < 0) {
          cout << "NO";
          return 0;
        }
      }
    }
  }
  cout << "YES" << endl;
  for (int i = 0; i < n; ++i) {
    cout << mas[i] << endl;
  }
  return 0;
}
