#include<bits/stdc++.h>
using namespace std;
typedef long int li;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define getc getchar
#define mid (l+ r>> 1)
const li mod= 1e9+ 7;
li nm[ 7], sz[ 7], n;
vector< pair< li, li> > want;
li req[ 7];
void prnt( li ths)
{
if( ths== 1) printf( "S");
if( ths== 2) printf( "M");
if( ths== 3) printf( "L");
if( ths== 4) printf( "XL");
if( ths== 5) printf( "XXL");
if( ths== 6) printf( "XXXL");
return;
}
void solve()
{
for( li i= 1; i<= 6; i++) scanf( "%ld", &sz[ i]);
scanf( "%ld", &n);
char S[ 100];
for( li i= 1; i<= n; i++)
{
getc();
scanf( "%s", S);
li a= 0, b= 0;
if( S[ 0]== 'S') a= 1;
if( S[ 0]== 'M') a= 2;
if( S[ 0]== 'L') a= 3;
if( S[ 0]== 'X')
{
if( S[ 1]== 'L') a= 4;
if( S[ 1]== 'X')
{
if( S[ 2]== 'L') a= 5;
if( S[ 2]== 'X') a= 6;
}
}
li st= 0, len= strlen( S);
while( st< len) if( S[ st++]== ',') b= a+ 1;
want. pb( mp( a, b) );
}
for( li i= 0; i< want. size(); i++) if( want[ i]. second== 0) req[ want[ i]. first]++;
for( li i= 1; i<= 6; i++)
{
sz[ i]-= req[ i];
nm[ i]= sz[ i];
req[ i]= 0;
if( sz[ i]< 0)
{
printf( "NO");
return;
}
}
for( li i= 0; i< want. size(); i++) if( want[ i]. second!= 0) req[ want[ i]. first]++;
for( li i= 1; i<= 6; i++)
{
sz[ i]-= req[ i];
req[ i]= 0;
if( sz[ i]< 0)
{
sz[ i+ 1]+= sz[ i];
sz[ i]= 0;
}
if( sz[ i+ 1]< 0)
{
printf( "NO");
return;
}
}
printf( "YES\n");
for( li i= 0; i< want. size(); i++)
{
if( want[ i]. second== 0)
{
prnt( want[ i]. first);
if( i< want. size()- 1) printf( "\n");
continue;
}
if( nm[ want[ i]. first]> 0)
{
prnt( want[ i]. first);
nm[ want[ i]. first]--;
if( i< want. size()- 1) printf( "\n");
continue;
}
prnt( want[ i]. second);
nm[ want[ i]. second]--;
if( i< want. size()- 1) printf( "\n");
}
return;
}
int main()
{
// freopen( "in", "r", stdin);
// freopen( "out", "w", stdout);
li T= 1;
// scanf( "%ld", &T);
while( T--)
{
// printf( "Case %ld: ", T+ 1);
solve();
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCnR5cGVkZWYgbG9uZyBpbnQgbGk7CnR5cGVkZWYgbG9uZyBsb25nIGxsOwojZGVmaW5lIG1wIG1ha2VfcGFpcgojZGVmaW5lIHBiIHB1c2hfYmFjawojZGVmaW5lIGdldGMgZ2V0Y2hhcgojZGVmaW5lIG1pZCAobCsgcj4+IDEpCmNvbnN0IGxpIG1vZD0gMWU5KyA3OwoKbGkgbm1bIDddLCBzelsgN10sIG47Cgp2ZWN0b3I8IHBhaXI8IGxpLCBsaT4gPiB3YW50OwoKbGkgcmVxWyA3XTsKCnZvaWQgcHJudCggbGkgdGhzKQp7CglpZiggdGhzPT0gMSkgcHJpbnRmKCAiUyIpOwoJaWYoIHRocz09IDIpIHByaW50ZiggIk0iKTsKCWlmKCB0aHM9PSAzKSBwcmludGYoICJMIik7CglpZiggdGhzPT0gNCkgcHJpbnRmKCAiWEwiKTsKCWlmKCB0aHM9PSA1KSBwcmludGYoICJYWEwiKTsKCWlmKCB0aHM9PSA2KSBwcmludGYoICJYWFhMIik7CgoJcmV0dXJuOwp9Cgp2b2lkIHNvbHZlKCkKewoJZm9yKCBsaSBpPSAxOyBpPD0gNjsgaSsrKSBzY2FuZiggIiVsZCIsICZzelsgaV0pOwoKCXNjYW5mKCAiJWxkIiwgJm4pOwoKCWNoYXIgU1sgMTAwXTsKCglmb3IoIGxpIGk9IDE7IGk8PSBuOyBpKyspCgl7CgkJZ2V0YygpOwoKCQlzY2FuZiggIiVzIiwgUyk7CgoJCWxpIGE9IDAsIGI9IDA7CgoJCWlmKCBTWyAwXT09ICdTJykgYT0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