#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

// TOP FRONT RIGHT LEFT BACK BOTTOM 
string list[24] = {
	"012345","024135","031425","043215","103254","120534",
	"135024","152304","201453","215043","240513","254103",
	"304152","310542","345012","351402","402351","425031",
	"430521","453201","513240","521430","534120","542310"
};

bool used[8];
string data[8];
char puzzle[6][8];

// ô:number , ï:face ÉÎµÄ¢éÏÈtH[}bgBIíèÍ-1B
int connect[8][8] = {
	{-1},
	{0,3,-1},
	{1,1,-1},
	{0,1,2,2,-1},
	{0,5,-1},
	{1,5,4,3,-1},
	{2,5,5,1,-1},
	{3,5,4,1,6,2,-1}
};

bool ok(char a,char b){
	return ( a != b ) && ( toupper(a) == toupper(b) );
}

bool backTrack(int s){
	if(s == 8) return true;
	
	for(int d = 0 ; d < 8 ; d++){
		if(used[d] != 0) continue;
		used[d] = true;
		for(int i = 0 ; i < 24 ; i++){
			for(int j = 0 ; j < 6 ; j++)
				puzzle[s][j] = data[d][list[i][j]]	;
			
			bool f = true;
			for(int j = 0 ; connect[s][j] != -1 ; j += 2){
				int pos  = connect[s][j];
				int face = connect[s][j+1];
				f &= ok(puzzle[pos][5-face], puzzle[s][face]);
			}
			if(f)if(backTrack(s+1))return true;
		}
		used[d] = false;
	}
	return false;
}
int main(){
	for(int i = 0 ; i < 24 ; i++)
		for(int j = 0 ; j < 6 ; j++)
			list[i][j] -= '0';

	while(cin >> data[0] , data[0] != "0"){
		for(int i = 1 ; i < 8 ; i++)
			cin >> data[i];
		memset(used,0,sizeof(used));
		cout << (backTrack(0)?"YES":"NO") << endl;
	}
}