#include<iostream>
#include<cstring>
#define rv(p,q) (a[c[p]][q]+('A'-'a')*('a'<=a[c[p]][q]&&a[c[p]][q]<='z'?1:-1))
using namespace std;
int fi();
int fj();
int fk();
int fl();
int fm();
int fn();
int fo();
char a[8][7];
int b[8],c[8];
enum ea{
  E,S,R,W,N,L,EE,SS,RR,NL
};
void rd(char a[],int p){
  static int b[6][4]={
    {0,3,5,2},
    {0,4,5,1},
    {1,2,4,3},
    {0,2,5,3},
    {0,1,5,4},
    {1,3,4,2}
  };
  int i;
  if(p==EE||p==SS||p==RR){
    rd(a,p-6);
    rd(a,p-6);
  }else{
    char s=a[b[p][0]];
    for(i=0;i<3;++i)
      a[b[p][i]]=a[b[p][i+1]];
    a[b[p][i]]=s;
  }
  return;
}
void rd(char a[],int p,int q,int r){
  static int b[6][6]={
    {NL,S,E,W,N,NL},
    {N,NL,L,R,NL,S},
    {W,R,NL,NL,L,E},
    {E,L,NL,NL,R,W},
    {S,NL,R,L,NL,N},
    {NL,N,W,E,S,NL}
  };
  b[0][5]=b[5][0]=(r==SS||r==EE?r:SS);
  b[1][4]=b[4][1]=(r==SS||r==RR?r:SS);
  b[2][3]=b[3][2]=(r==EE||r==RR?r:EE);
  if(b[p][q]!=NL)
    rd(a,b[p][q]);
  return;
}
int fi(){
  int i,j,k;
  for(i=0;i<8;++i){
    if(b[i]){
      b[i]=0;
      c[1]=i;
      for(j=0;j<6;++j){	
	if(a[i][j]==rv(0,2)){
	  rd(a[i],j,3,SS);
	  for(k=0;k<4;++k){
	    if(fj())
	      return 1;
	    rd(a[i],N);
	  }
	  rd(a[i],3,j,SS);
	}
      }
      b[i]=-1;
    }
  }
  return 0;
}
int fj(){
  int i,j,k;
  for(i=0;i<8;++i){
    if(b[i]){
      b[i]=0;
      c[2]=i;
      for(j=0;j<6;++j){	
	if(a[i][j]==rv(0,4)){
	  rd(a[i],j,1,SS);
	  for(k=0;k<4;++k){
	    if(fk())
	      return 1;
	    rd(a[i],E);
	  }
	  rd(a[i],1,j,SS);
	}
      }
      b[i]=-1;
    }
  }
  return 0;
}
int fk(){
  int i,j,k;
  for(i=0;i<8;++i){
    if(b[i]){
      b[i]=0;
      c[3]=i;
      for(j=0;j<6;++j){
	if(a[i][j]==rv(1,4)){
	  rd(a[i],j,1,SS);
	  for(k=0;k<6;++k){
	    if(k!=1&&k!=4&&a[i][k]==rv(2,2)){
	      rd(a[i],k,3,EE);
	      if(fl())
		return 1;
	      rd(a[i],3,k,EE);
	    }
	  }
	  rd(a[i],1,j,SS);
	}
      }
      b[i]=-1;
    }
  }
  return 0;
}
int fl(){
  int i,j,k;
  for(i=0;i<8;++i){
    if(b[i]){
      b[i]=0;
      c[4]=i;
      for(j=0;j<6;++j){	
	if(a[i][j]==rv(0,0)){
	  rd(a[i],j,5,SS);
	  for(k=0;k<4;++k){
	    if(fm())
	      return 1;
	    rd(a[i],R);
	  }
	  rd(a[i],5,j,SS);
	}
      }
      b[i]=-1;
    }
  }
  return 0;
}
int fm(){
  int i,j,k;
  for(i=0;i<8;++i){
    if(b[i]){
      b[i]=0;
      c[5]=i;
      for(j=0;j<6;++j){
	if(a[i][j]==rv(1,0)){
	  rd(a[i],j,5,SS);
	  for(k=0;k<6;++k){
	    if(k!=0&&k!=5&&a[i][k]==rv(4,2)){
	      rd(a[i],k,3,RR);
	      if(fn())
		return 1;
	      rd(a[i],3,k,RR);
	    }
	  }
	  rd(a[i],5,j,SS);
	}
      }
      b[i]=-1;
    }
  }
  return 0;
}
int fn(){
  int i,j,k;
  for(i=0;i<8;++i){
    if(b[i]){
      b[i]=0;
      c[6]=i;
      for(j=0;j<6;++j){
	if(a[i][j]==rv(2,0)){
	  rd(a[i],j,5,SS);
	  for(k=0;k<6;++k){
	    if(k!=0&&k!=5&&a[i][k]==rv(4,4)){
	      rd(a[i],k,1,RR);
	      if(fo())
		return 1;
	      rd(a[i],1,k,RR);
	    }
	  }
	  rd(a[i],5,j,SS);
	}
      }
      b[i]=-1;
    }
  }
  return 0;
}
int fo(){
  int i,j,k;
  for(i=0;i<8;++i){
    if(b[i]){
      b[i]=0;
      c[7]=i;
      for(j=0;j<6;++j){
	if(a[i][j]==rv(3,0)){
	  rd(a[i],j,5,SS);
	  for(k=0;k<6;++k){
	    if(k!=0&&k!=5&&a[i][k]==rv(5,4)){
	      rd(a[i],k,1,RR);
	      if(a[i][3]==rv(6,2))
		return 1;
	      rd(a[i],1,k,RR);
	    }
	  }
	  rd(a[i],5,j,SS);
	}
      }
      b[i]=-1;
    }
  }
  return 0;
}
int main(){
  int i;
  while(cin>>a[0],a[0][0]!='0'){
    for(i=1;i<8;++i)
      cin>>a[i];
    memset(b,-1,sizeof(b));
    b[0]=0;
    c[0]=0;
    int d[24]={L,L,L,E,L,L,L,E,L,L,L,W,L,L,L,W,L,L,L,E,L,L,L,L};
    for(i=0;i<24;++i){
      if(fi())
	break;
      rd(a[0],d[i]);
    }
    if(i<24)
      cout<<"YES"<<endl;
    else
      cout<<"NO"<<endl;
  }
  return 0;
}

Measured memory_bytes: 852