#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100100;
int N;
int cnt[6];
vector<int> only[6];
vector<pair<int, int> > both[6];
bool used[MAXN];
map<string, int> mp;
string ans[6] = {"S", "M", "L", "XL", "XXL", "XXXL"};
int T[MAXN];
bool check() {
  for (int i = 0; i < N; i++)
    if (!used[i]) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  mp["S"] = 0;
  mp["M"] = 1;
  mp["L"] = 2;
  mp["XL"] = 3;
  mp["XXL"] = 4;
  mp["XXXL"] = 5;
  for (int i = 0; i < 6; i++) cin >> cnt[i];
  cin >> N;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    int idx = 0;
    for (; idx < s.size(); idx++)
      if (s[idx] == ',') break;
    if (idx == (int)s.size())
      only[mp[s]].push_back(i);
    else {
      int x = mp[s.substr(0, idx)];
      both[x].push_back(make_pair(1, i));
      both[x + 1].push_back(make_pair(0, i));
    }
  }
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < only[i].size() && cnt[i] > 0; j++) {
      T[only[i][j]] = i;
      cnt[i]--;
      used[only[i][j]] = true;
    }
    sort(both[i].begin(), both[i].end());
    for (int j = 0; j < both[i].size() && cnt[i] > 0; j++) {
      if (used[both[i][j].second]) continue;
      T[both[i][j].second] = i;
      cnt[i]--;
      used[both[i][j].second] = true;
    }
  }
  if (check()) {
    cout << "YES\n";
    for (int i = 0; i < N; i++) cout << ans[T[i]] << "\n";
  } else
    cout << "NO\n";
  return 0;
}
