#include <bits/stdc++.h>   using namespace std;   template <class T>   inline T mod_v(T num) {     if (num >= 0)       return num % 1000000007;     else       return (num % 1000000007 + 1000000007) % 1000000007;   }   template <class T>   inline T gcd(T a, T b) {     a = abs(a);     b = abs(b);     while (b) b ^= a ^= b ^= a %= b;     return a;   }   template <class T>   T fast_pow(T n, T p) {     if (p == 0) return 1;     if (p % 2) {       T g = mod_v(mod_v(n) * mod_v(fast_pow(n, p - 1)));       return g;     } else {       T g = fast_pow(n, p / 2);       g = mod_v(mod_v(g) * mod_v(g));       return g;     }   }   template <class T>   inline T modInverse(T n) {     return fast_pow(n, 1000000007 - 2);   }   bool equalTo(double a, double b) {     if (fabs(a - b) <= 1e-9)       return true;     else       return false;   }   bool notEqual(double a, double b) {     if (fabs(a - b) > 1e-9)       return true;     else       return false;   }   bool lessThan(double a, double b) {     if (a + 1e-9 < b)       return true;     else       return false;   }   bool lessThanEqual(double a, double b) {     if (a < b + 1e-9)       return true;     else       return false;   }   bool greaterThan(double a, double b) {     if (a > b + 1e-9)       return true;     else       return false;   }   bool greaterThanEqual(double a, double b) {     if (a + 1e-9 > b)       return true;     else       return false;   }   struct debugger {     template <typename T>     debugger& operator,(const T& v) {       cerr << v <<    ;       return *this;     }   } dbg;   int nextInt() {     int n;     scanf( %d , &n);     return n;   }   long long nextLong() {     long long n;     scanf( %lld , &n);     return n;   }   void print(int n) { printf( %d , n); }   void println(int n) { printf( %d n , n); }   void println(long long n) { printf( %lld n , n); }   template <class T>   inline int in(register T& num) {     register char c = 0;     num = 0;     bool n = false;     while (c < 33) c = getchar();     while (c > 33) {       if (c ==  - )         n = true;       else         num = num * 10 + c -  0 ;       c = getchar();     }     num = n ? -num : num;     return 1;   }   string tshirt[] = { S ,  M ,  L ,  XL ,  XXL ,  XXXL };   int cnt[10];   string res[1000004];   int main() {     int var;     int n;     map<string, int> val;     for (int i = 0; i < 6; i++) {       in(var);       val[tshirt[i]] = i;       cnt[i] = var;     }     in(n);     bool ok = true;     vector<pair<int, pair<int, int> > > pos;     for (int i = 1; i <= n; i++) {       char s[10];       char* tmp;       char v[] =  , ;       scanf( %s , s);       if (!ok) continue;       tmp = strtok(s, v);       int l = 100, r = -1;       while (tmp != NULL) {         l = min(l, val[tmp]);         r = max(r, val[tmp]);         tmp = strtok(NULL, v);       }       if (l == r) {         if (cnt[l] == 0)           ok = false;         else {           cnt[l]--;           res[i] = tshirt[l];         }       } else         pos.push_back({l, {r, i}});     }     sort((pos).begin(), (pos).end());     for (auto i : pos) {       if (!ok) break;       if (cnt[i.first]) {         cnt[i.first]--;         res[i.second.second] = tshirt[i.first];       } else if (cnt[i.second.first]) {         cnt[i.second.first]--;         res[i.second.second] = tshirt[i.second.first];       } else         ok = false;     }     if (!ok)       printf( NO n );     else {       printf( YES n );       for (int i = 1; i <= n; i++) cout << res[i] <<   n ;     }     return 0;   }