char a[9];i;main(b){gets(a-2);for(;(b=~getchar())&&b+11&i-9;a[i]=0)for(i=-3;++i<9&&a[i]-~b;);i=!printf(i-9?"YES":"NO");}