

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

std::vector<std::string> buf(8);

//Eñ]ÉiÞûüÅ³ÊÌCfbNXÆAEÌCfbNXðwèµÄãÌCfbNXðÔ·
int uppderindex(int front, int right){
	int table[][6] = {
		{0, 3, 5, 2, 4, 0},
		{4, 0, 1, 6, 0, 3},
		{2, 6, 0, 0, 1, 5},
		{5, 1, 0, 0, 6, 2},
		{3, 0, 6, 1, 0, 4},
		{0, 4, 2, 5, 3, 0}
	};
	return table[front][right]-1;
}
//½Î¤ÌCfbNXðÔ·
int otherindex(int h){
	return 5-h;
}
int otherc(int c){
	return c+(c>96?-32:32);
}
//³ÊðwèµÄOüÌCfbNXðÔ·
int aroundindex(int front, int idx){
	for(int i=0,cnt=0; i<6; i++){
		if(front!=i&&otherindex(front)!=i){
			if(cnt==idx) return i;
			cnt++;
		}
	}
	return 0;
}

int dindexlist[4];
int uindexlist[4];
int firstindex;
int firstindex2;

bool same(int *arr){
	for(int i=0; i<4; i++){
		if( otherc(buf[arr[i]][otherindex(dindexlist[i])]) != 
			buf[(arr+4)[i]][uindexlist[i]] )
			return false;
	}
	return true;
}

bool check_around2(int *d, int idx, int nest, int *arr){
	int c = otherc(buf[*d][idx]);
	if( nest == 3 ){
		//±êÍÅÌ³¢±ëÆêv·é©ð©éàÌÈÌÅÁÊ
		for(int around=0; around<4; around++){
			int ar = aroundindex(firstindex2,around);
			if( c == buf[*(d-3)][ar] ){ //¡Ì¶ª éÆl¦éÌÍÊ|I
				//ÅÌ³¢±ëÌãCfbNX
				arr[0] = uppderindex( ar, firstindex2 );
				return true;
			}
		}
		return false;
	}

	//Ì³¢±ë
	d++;
	for(int i=0; i<6; i++){
		if( c == buf[*d][i] ){
			for(int around=0; around<4; around++){
				int ar = aroundindex(i,around);

				//CfbNXÌXg¶áÈ­Ä¶ñÉµ½Ù¤ª¢¢©È
				arr[nest+1] = uppderindex( i, ar );
				if( check_around2(d, ar, nest+1, arr) ){
					if( nest == 2 ){
						//OóÉÂÈªÁÄéÌªmèµÄÜ·
						if( same(d-7) ) return true;
					}else{
						return true;
					}
				}
			}
		}
	}
	return false;
}

bool check2(int* d, int* idxlist){
	for(int i=0; i<6; i++){ //³¢±ëÌ»ê¼êÌ¶ÉÂ¢Ä²×é
		if( check_around2(d, firstindex2=i, 0, idxlist) ) return true;
	}
	return false;
}



bool check_around(int *d, int idx, int nest, int *arr){
	int c = otherc(buf[*d][idx]);
	if( nest == 3 ){
		//±êÍÅÌ³¢±ëÆêv·é©ð©éàÌÈÌÅÁÊ
		for(int around=0; around<4; around++){
			int ar = aroundindex(firstindex,around);
			if( c == buf[*(d-3)][ar] ){ //¡Ì¶ª éÆl¦éÌÍÊ|I
				//ÅÌ³¢±ëÌãCfbNX
				arr[0] = uppderindex( ar, firstindex );
				return true;
			}
		}
		return false;
	}

	//Ì³¢±ë
	d++;
	for(int i=0; i<6; i++){
		if( c == buf[*d][i] ){
			for(int around=0; around<4; around++){
				int ar = aroundindex(i,around);

				//CfbNXÌXg¶áÈ­Ä¶ñÉµ½Ù¤ª¢¢©È
				arr[nest+1] = uppderindex( i, ar );
				if( check_around(d, ar, nest+1, arr) ){
					if( nest == 2 ){
						//OóÉÂÈªÁÄéÌªmèµÄÜ·
						if( check2( d+1, uindexlist ) ) return true;
					}else{
						return true;
					}
				}
			}
		}
	}
	return false;
}

bool check(int* d, int* idxlist){
	for(int i=0; i<6; i++){ //³¢±ëÌ»ê¼êÌ¶ÉÂ¢Ä²×é
		if( check_around(d, firstindex=i, 0, idxlist) ) return true;
	}
	return false;
}

bool check_around_pre(int *d, int idx, int nest){
	int c = otherc(buf[*d][idx]);
	if( nest == 3 ){
		//±êÍÅÌ³¢±ëÆêv·é©ð©éàÌÈÌÅÁÊ
		for(int around=0; around<4; around++){
			int ar = aroundindex(firstindex,around);
			if( c == buf[*(d-3)][ar] ) return true;
		}
		return false;
	}

	//Ì³¢±ë
	d++;
	for(int i=0; i<6; i++){
		if( c == buf[*d][i] ){
			for(int around=0; around<4; around++){
				int ar = aroundindex(i,around);
				if( check_around_pre(d, ar, nest+1) ) return true;
			}
		}
	}
	return false;
}

bool check_pre(int* d){
	for(int i=0; i<6; i++){ //³¢±ëÌ»ê¼êÌ¶ÉÂ¢Ä²×é
		if( check_around_pre(d, firstindex=i, 0) ) return true;
	}
	return false;
}

bool get(){
	for(int i=0; i<8; ++i){
		std::getline(std::cin,buf[i]);
		if(buf[i]=="0")return false;
	}
	return true;
}
int main(){
	while(get()){
		int d[8] = {0,1,2,3,4,5,6,7};
		do{
			//Æè ¦¸2ÂÚÌXgÍìÁÄÌÄçêéñª½·¬éÌÅAæÉ1ÂÅà¶Ý·é©Ç¤©Å}Øè·é
			if( check(d,dindexlist) ){
				puts("YES");
				goto next;
			}
		}while(std::next_permutation(d, d+8));
		puts("NO");
next:
		;
	}
}