#include<iostream>
#include<string>
#include<cassert>
#include<cctype>

#define NUM 8
#define SIDES 6
#define MAX 128
using namespace std;

char ChangeCase(char c){
	if( isupper( c ) )
		return tolower( c );
	else
		return toupper( c );
}

struct Dice{
	Dice():s(""){
		for(int i = 0; i < MAX; ++i){
			ch[i] = false;
		}
	}
	string s;
	bool ch[MAX];
	void Make(){
		for(unsigned int i = 0; i < s.length(); ++i){
			ch[ s[i] ] = true;
		}
	}
	char GetSide(int side)const{
		return s[side];
	}
	bool Contains(char c)const{
		return ch[ c ];
	}
	void RotHor(){
		char c[SIDES];
		c[0] = s[0]; c[1] = s[3]; c[2] = s[1]; c[3] = s[4]; c[4] = s[2]; c[5] = s[5];
		for(unsigned int i = 0; i < SIDES; ++i)
			s[i] = c[i];
	}
	void RotVer(){
		char c[SIDES];
		c[0] = s[4]; c[1] = s[0]; c[2] = s[2]; c[3] = s[3]; c[4] = s[5]; c[5] = s[1];
		for(unsigned int i = 0; i < SIDES; ++i)
			s[i] = c[i];
	}
	void Rot(){
		char c[SIDES];
		c[0] = s[2]; c[1] = s[1]; c[2] = s[5]; c[3] = s[0]; c[4] = s[4]; c[5] = s[3];
		for(unsigned int i = 0; i < SIDES; ++i)
			s[i] = c[i];
	}
	void Set(char c, int side){
		int pos;
		for(unsigned int i = 0; i < s.length(); ++i){
			if( s[i] == c ){
				pos = i;
				break;
			}
		}
		switch( pos ){
			case 0:
				switch( side ){
					case 0: break;
					case 1: RotVer(); break;
					case 2: RotVer(); RotHor(); break;
					case 3: Rot(); break;
					case 4: RotVer(); RotVer(); RotVer(); break;
					case 5: RotVer(); RotVer(); break;
				}
				break;
			case 1:
				switch( side ){
					case 0: RotHor(); Rot(); break;
					case 1: break;
					case 2: RotHor(); break;
					case 3: RotHor(); RotHor(); RotHor(); break;
					case 4: RotHor(); RotHor(); break;
					case 5: RotVer(); break;
				}
				break;
			case 2:
				switch( side ){
					case 0: Rot(); break;
					case 1: Rot(); RotVer(); break;
					case 2: break;
					case 3: Rot(); Rot(); break;
					case 4: RotHor(); break;
					case 5: Rot(); RotVer(); RotVer(); break;
				}
				break;
			case 3:
				switch( side ){
					case 0: Rot(); Rot(); Rot(); break;
					case 1: RotHor(); break;
					case 2: Rot(); Rot(); break;
					case 3: break;
					case 4: Rot(); RotVer(); break;
					case 5: RotHor(); RotVer(); break;
				}
				break;
			case 4:
				switch( side ){
					case 0: RotVer(); break;
					case 1: RotHor(); RotHor(); break;
					case 2: RotHor(); RotHor(); RotHor(); break;
					case 3: RotHor(); break;
					case 4: break;
					case 5: RotHor(); Rot(); break;
				}
				break;
			case 5:
				switch( side ){
					case 0: Rot(); Rot(); break;
					case 1: RotVer(); RotVer(); RotVer(); break;
					case 2: Rot(); break;
					case 3: RotVer(); RotHor(); break;
					case 4: RotVer(); break;
					case 5: break;
				}
				break;
		}
		assert( GetSide( side ) == c );
	}
};
bool solve(Dice ans[NUM], const Dice pzl[NUM], bool bUse[NUM], int pos ){
	if( pos >= 8 )
		return true;

	if( pos == 0 ){
		//for(unsigned int k = 0; k < NUM; ++k){
		int k = 0;
			ans[pos] = pzl[k];
			bUse[k] = true;
			for(unsigned int i = 0; i < 6; ++i ){
				ans[pos].Set( pzl[k].s[i], 0 );
				for(unsigned int j = 0; j < 4; ++j ){
					if( solve( ans, pzl, bUse, pos + 1 ) )
						return true;
					ans[pos].RotHor();
				}
			}
			bUse[k] = false;
		//}
	}else if( pos == 1 ){
		char c = ans[0].GetSide(2);
		for(unsigned int i = 0; i < NUM; ++i){
			char C = ChangeCase( c );
			if( !bUse[i] && pzl[i].Contains( C ) ){
				ans[pos] = pzl[i];

				bUse[i] = true;
				ans[pos].Set( C, 3 );
				for(unsigned int j = 0; j < 4; ++j){	
					if( solve( ans, pzl, bUse, pos+1 ) )
						return true;
					ans[pos].RotVer();
				}
				bUse[i] = false;
			}
		}
	}else if( pos == 2 ){
		char c = ans[1].GetSide(4);
		for(unsigned int i = 0; i < NUM; ++i){
			char C = ChangeCase( c );
			if( !bUse[i] && pzl[i].Contains( C ) ){
				ans[pos] = pzl[i];

				bUse[i] = true;
				ans[pos].Set( C, 1 );
				for(unsigned int j = 0; j < 4; ++j){	
					if( solve( ans, pzl, bUse, pos+1 ) )
						return true;
					ans[pos].Rot();
				}
				bUse[i] = false;
			}
		}
	}else if( pos == 3 ){
		char c = ans[2].GetSide(3);
		char val_c = ans[0].GetSide(4);
		for(unsigned int i = 0; i < NUM; ++i){
			char C = ChangeCase( c );
			if( !bUse[i] && pzl[i].Contains( C ) ){
				ans[pos] = pzl[i];

				bUse[i] = true;
				ans[pos].Set( C, 2 );
				for(unsigned int j = 0; j < 4; ++j){	
					if( ans[pos].GetSide(1) == ChangeCase( val_c ) ){
						if( solve( ans, pzl, bUse, pos+1 ) )
							return true;
					}
					ans[pos].RotVer();
				}
				bUse[i] = false;
			}
		}
	}else if( pos == 4 ){
		char c = ans[0].GetSide(5);
		for(unsigned int i = 0; i < NUM; ++i){
			char C = ChangeCase( c );
			if( !bUse[i] && pzl[i].Contains( C ) ){
				ans[pos] = pzl[i];

				bUse[i] = true;
				ans[pos].Set( C, 0 );
				for(unsigned int j = 0; j < 4; ++j){	
					if( solve( ans, pzl, bUse, pos+1 ) )
						return true;
					ans[pos].RotHor();
				}
				bUse[i] = false;
			}
		}
	}else if( pos == 5 ){
		char c = ans[4].GetSide(2);
		char val_c = ans[1].GetSide(5);
		for(unsigned int i = 0; i < NUM; ++i){
			char C = ChangeCase( c );
			if( !bUse[i] && pzl[i].Contains( C ) ){
				ans[pos] = pzl[i];

				bUse[i] = true;
				ans[pos].Set( C, 3 );
				for(unsigned int j = 0; j < 4; ++j){	
					if( ans[pos].GetSide( 0 ) == ChangeCase( val_c ) ){
						if( solve( ans, pzl, bUse, pos+1 ) )
							return true;
					}
					ans[pos].RotVer();
				}
				bUse[i] = false;
			}
		}
	}else if( pos == 6 ){
		char c = ans[5].GetSide(4);
		char val_c = ans[2].GetSide(5);
		for(unsigned int i = 0; i < NUM; ++i){
			char C = ChangeCase( c );
			if( !bUse[i] && pzl[i].Contains( C ) ){
				ans[pos] = pzl[i];

				bUse[i] = true;
				ans[pos].Set( C, 1 );
				for(unsigned int j = 0; j < 4; ++j){	
					if( ans[pos].GetSide( 0 ) == ChangeCase( val_c ) ){
						if( solve( ans, pzl, bUse, pos+1 ) )
							return true;
					}
					ans[pos].Rot();
				}
				bUse[i] = false;
			}
		}
	}else if( pos == 7 ){
		char c = ans[6].GetSide(3);
		char val_c = ans[3].GetSide(5);
		char val_comp = ans[4].GetSide(4);
		for(unsigned int i = 0; i < NUM; ++i){
			char C = ChangeCase( c );
			if( !bUse[i] && pzl[i].Contains( C ) ){
				ans[pos] = pzl[i];

				bUse[i] = true;
				ans[pos].Set( C, 2 );
				for(unsigned int j = 0; j < 4; ++j){	
					if( ans[pos].GetSide( 0 ) == ChangeCase( val_c ) &&
						ans[pos].GetSide( 1 ) == ChangeCase( val_comp ) ){
						if( solve( ans, pzl, bUse, pos+1 ) )
							return true;
					}
					ans[pos].RotVer();
				}
				bUse[i] = false;
			}
		}
	}
	return false;
}
int main(){
	while(true){
		Dice ans[NUM];
		Dice pzl[NUM];
		bool bUse[NUM] = {0,};
		
		for(int i = 0; i < 8; ++i){
			string s;
			cin >> s;
			if( s[0] == '0' )
				return 0;
			pzl[i].s = s;
			pzl[i].Make();
		}
		if( solve( ans, pzl, bUse, 0 ) )
			cout << "YES\n";
		else
			cout << "NO\n";
	}
	return 0;
}