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

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

//Eñ]ÉiÞûüÅ³ÊÌCfbNXÆAEÌCfbNXðwèµÄãÌCfbNXðÔ·
inline 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;
}
//½Î¤ÌCfbNXðÔ·
inline int otherindex(int h){
	return 5-h;
}
inline int otherc(int c){
	return c+(c>96?-32:32);
}
//³ÊðwèµÄOüÌCfbNXðÔ·
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
				//ÅÌ³¢±ëÌãCfbNX
				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);

				//CfbNXÌXg¶áÈ­Ä¶ñÉµ½Ù¤ª¢¢©È
				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
				//ÅÌ³¢±ëÌãCfbNX
				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);

				//CfbNXÌXg¶áÈ­Ä¶ñÉµ½Ù¤ª¢¢©È
				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};
		for(int i=1; i<8; ++i){
			d[5] = i;
			int d2[6];
			int addi = 1;
			for(int j=0; j<6; ++j){
				d2[j] = addi==i?++addi:addi;
				++addi;
			}
			do{
				d[3] = d2[2];
				d[4] = d2[3];
				d[6] = d2[4];
				d[7] = d2[5];
				for(int k=0; k<2; ++k){
					d[1+k] = d2[0];
					d[2-k] = d2[1];
					//Æè ¦¸2ÂÚÌXgÍìÁÄÌÄçêéñª½·¬éÌÅAæÉ1ÂÅà¶Ý·é©Ç¤©Å}Øè·é
					if( check_pre(d) && check_pre(d+4) && check(d,dindexlist) ){
						puts("YES");
						goto next;
					}
				}
			}while(std::next_permutation(d2+1, d2+6));
		}
		puts("NO");
next:
		;
	}
}

Measured memory_bytes: 888