#include <bits/stdc++.h>
using namespace std;
int main() {
  int k, n, t;
  bool fl, f;
  string s;
  vector<int> a;
  vector<int> b(5);
  vector<int> d(10);
  for (int i = 0; i < 6; i++) {
    cin >> k;
    a.push_back(k);
  }
  cin >> n;
  vector<int> c(n);
  for (int i = 0; i < n; i++) {
    cin >> s;
    t = 0;
    fl = false;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] == ',') {
        fl = true;
        if (t == 'S') {
          b[0]++;
          c[i] = 7;
          break;
        }
        if (t == 'M') {
          b[1]++;
          c[i] = 8;
          break;
        }
        if (t == 'L') {
          b[2]++;
          c[i] = 9;
          break;
        }
        if (t == 'X' + 'L') {
          b[3]++;
          c[i] = 10;
          break;
        }
        b[4]++;
        c[i] = 11;
        break;
      } else {
        t += s[j];
      }
    }
    if (!fl) {
      if (t == 'S') {
        a[0]--;
        c[i] = 1;
      } else {
        if (t == 'M') {
          a[1]--;
          c[i] = 2;
        } else {
          if (t == 'L') {
            a[2]--;
            c[i] = 3;
          } else {
            if (t == 'X' + 'L') {
              a[3]--;
              c[i] = 4;
            } else {
              if (t == 'X' + 'X' + 'L') {
                a[4]--;
                c[i] = 5;
              } else {
                a[5]--;
                c[i] = 6;
              }
            }
          }
        }
      }
    }
  }
  f = true;
  for (int i = 0; i < 6; i++) {
    if (a[i] < 0) {
      f = false;
      break;
    } else {
      if (i == 0) {
        b[0] -= a[0];
        d[0] = a[0];
      } else {
        if (i >= 1 && i < 5) {
          a[i] -= max(b[i - 1], 0);
          if (a[i] < 0) {
            f = false;
            break;
          } else {
            b[i] -= a[i];
            d[2 * i] = a[i];
          }
        } else {
          if (b[4] > a[5]) {
            f = false;
            break;
          } else {
            d[9] = a[5];
          }
        }
      }
    }
  }
  if (!f) {
    cout << "NO";
  } else {
    cout << "YES\n";
    for (int i = 0; i < n; i++) {
      if (c[i] == 1) {
        cout << "S\n";
        continue;
      }
      if (c[i] == 2) {
        cout << "M\n";
        continue;
      }
      if (c[i] == 3) {
        cout << "L\n";
        continue;
      }
      if (c[i] == 4) {
        cout << "XL\n";
        continue;
      }
      if (c[i] == 5) {
        cout << "XXL\n";
        continue;
      }
      if (c[i] == 6) {
        cout << "XXXL\n";
        continue;
      }
      if (c[i] == 7) {
        if (d[0] > 0) {
          cout << "S\n";
          d[0]--;
        } else {
          cout << "M\n";
        }
        continue;
      }
      if (c[i] == 8) {
        if (d[2] > 0) {
          cout << "M\n";
          d[2]--;
        } else {
          cout << "L\n";
        }
        continue;
      }
      if (c[i] == 9) {
        if (d[4] > 0) {
          cout << "L\n";
          d[4]--;
        } else {
          cout << "XL\n";
        }
        continue;
      }
      if (c[i] == 10) {
        if (d[6] > 0) {
          cout << "XL\n";
          d[6]--;
        } else {
          cout << "XXL\n";
        }
        continue;
      } else {
        if (d[8] > 0) {
          cout << "XXL\n";
          d[8]--;
        } else {
          cout << "XXXL\n";
        }
      }
    }
  }
  return 0;
}
