#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 5, mod = 1e9 + 7, bit = 60;
long long int n;
string s, ans[N];
std::vector<pair<long long int, long long int> > q;
map<string, long long int> mp;
vector<string> v = {"S", "M", "L", "XL", "XXL", "XXXL"};
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long int i, j, x, freq[6] = {0};
  for (i = 0; i < 6; i++) {
    mp[v[i]] = i;
    cin >> freq[i];
  }
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s;
    long long int l = s.length();
    for (j = 0; j < l; j++) {
      if (s[j] == ',') {
        break;
      }
    }
    if (j < l) {
      string s1 = s.substr(0, j);
      x = mp[s1];
      s1 = s.substr(j + 1, l - (j + 1));
      x = min(x, mp[s1]);
      q.push_back({x, i});
    } else {
      x = mp[s];
      if (freq[x] <= 0) {
        return cout << "NO\n", 0;
      }
      ans[i] = s;
      freq[x]--;
    }
  }
  sort(q.begin(), q.end());
  i = 0;
  j = 0;
  while (i < q.size() and j < 6) {
    while (j < q[i].first) {
      j++;
    }
    while (j < 6 and freq[j] == 0) {
      j++;
    }
    if (j > q[i].first + 1) {
      break;
    }
    ans[q[i].second] = v[j];
    i++;
    freq[j]--;
  }
  if (i != q.size()) {
    return cout << "NO\n", 0;
  }
  cout << "YES\n";
  for (i = 0; i < n; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}
