#include <bits/stdc++.h>
const long double EPS = 1e-10;
const long long int MOD = 1000000007ll;
const long long int mod1 = 1000000009ll;
const long long int mod2 = 1100000009ll;
int INF = (int)1e9;
long long int INFINF = (long long int)1e18;
int debug = 0;
using namespace std;
long long int bit_count(long long int _x) {
  long long int _ret = 0;
  while (_x) {
    if (_x % 2 == 1) _ret++;
    _x /= 2;
  }
  return _ret;
}
long long int bit(long long int _mask, long long int _i) {
  return (_mask & (1 << _i)) == 0 ? 0 : 1;
}
long long int powermod(long long int _a, long long int _b,
                       long long int _m = MOD) {
  long long int _r = 1;
  while (_b) {
    if (_b % 2 == 1) _r = (_r * _a) % _m;
    _b /= 2;
    _a = (_a * _a) % _m;
  }
  return _r;
}
long long int add(long long int a, long long int b, long long int m = MOD) {
  long long int x = a + b;
  while (x >= m) x -= m;
  return x;
}
long long int sub(long long int a, long long int b, long long int m = MOD) {
  long long int x = a - b;
  while (x < 0) x += m;
  return x;
}
long long int mul(long long int a, long long int b, long long int m = MOD) {
  long long int x = a * 1ll * b;
  x %= m;
  if (x < m) x += m;
  return x;
}
int n;
map<string, int> Map;
string rMap[10];
int a[10];
char tempssss[100];
string ans[100010];
vector<int> b[10];
bool rem[100010];
bool comma(string s) {
  for (char c : s)
    if (c == ',') return true;
  return false;
}
int main() {
  if (0) {
    freopen("input.txt", "r", stdin);
    debug = 1;
  }
  srand(time(NULL));
  Map["S"] = 1;
  rMap[1] = "S";
  Map["M"] = 2;
  rMap[2] = "M";
  Map["L"] = 3;
  rMap[3] = "L";
  Map["XL"] = 4;
  rMap[4] = "XL";
  Map["XXL"] = 5;
  rMap[5] = "XXL";
  Map["XXXL"] = 6;
  rMap[6] = "XXXL";
  for (int i = 1; i <= 6; i++) scanf("%d", &a[i]);
  scanf("%d", &n);
  for (int tttt = 1; tttt <= n; tttt++) {
    string s;
    scanf("%s", tempssss);
    ;
    s = tempssss;
    if (comma(s)) {
      string s1 = "", s2 = "";
      int i;
      for (i = 0; i < s.size(); i++) {
        if (s[i] == ',') break;
        s1 += s[i];
      }
      i++;
      for (; i < s.size(); i++) s2 += s[i];
      b[Map[s1]].push_back(tttt);
    } else {
      int m = Map[s];
      if (a[m] == 0) {
        cout << "NO";
        return 0;
      }
      a[m]--;
      ans[tttt] = s;
    }
  }
  for (int i = 1; i <= 5; i++) {
    for (int j : b[i]) {
      if (a[i] == 0) {
        if (a[i + 1] == 0) {
          cout << "NO";
          return 0;
        } else {
          a[i + 1]--;
          ans[j] = rMap[i + 1];
        }
      } else {
        a[i]--;
        ans[j] = rMap[i];
      }
    }
  }
  cout << "YES\n";
  for (int i = 1; i <= n; i++) cout << ans[i] << "\n";
  return 0;
}
