Problem: There is a dice with one letter of the alphabet (a ~ z, A ~ Z) drawn on each side.


<image>


Consider combining eight such dice to make a 2 x 2 x 2 cube.


<image>


There are conditions on how to combine the dice, and the facing faces of each dice must have the same alphabet, one in lowercase and the other in uppercase. For example, a surface marked a can be touched by a face marked A. However, the orientation of the characters when touching them does not matter.


<image>


According to this rule, input the information of 8 dice and create a program to judge whether or not you can make a cube. If you can make a cube, output YES (half-width uppercase letters), and if you cannot make it, output NO (half-width uppercase letters).

The letters on each side of the dice will be represented as c1 to c6 as shown in the following figure. Also, assume that the same letter is never drawn multiple times on a single dice (uppercase and lowercase letters of the same alphabet are not the case).


<image>



Input

A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:


s1
s2
::
s8


The i-line gives the information si of the i-th dice. si is a string of length 6 and the jth character corresponds to each side cj of the dice.

The number of datasets does not exceed 50.

Output

The judgment result (half-width uppercase letters) is output to one line for each data set.

Example

Input

zabZNq
BCxmAi
ZcbBCj
aizXCm
QgmABC
JHzMop
ImoXGz
MZTOhp
zabZnQ
BCxmAi
ZcbBCj
aizXCm
QgmABC
JHzMop
ImoXGz
MZTOhp
abcdef
ABDCFE
FBDCAE
abcdef
BEACDF
bfcaed
fabcde
DEABCF
UnivOf
AizuaH
zTXZYW
piglIt
GRULNP
higGtH
uAzIXZ
FizmKZ
UnivOf
AizuaH
piglIt
higGtH
GRULNP
uAzIXZ
FizmKZ
ZTXzYW
0


Output

YES
NO
YES
YES
NO

Solution (in CPP):

Solution:
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

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];
vector<string> data(8);
vector<string> puzzle(8);

// TOP FRONT RIGHT LEFT BACK BOTTOM 

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 && (a&~32) == (b&~32);
}

bool backTrack(int s){
	if(s == 8){
		//for(int i = 0 ; i < 8 ; i++)
		//	cout << "[" << puzzle[i].dice << "]"  << endl;
		return true;
	}
	for(int d = 0 ; d < 8 ; d++){
		if(used[d] != 0) continue;
		used[d] = true;
		puzzle[s] = data[d];
		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] ; j += 2){
				int pos  = connect[s][j];
				int face = connect[s][j+1];
				if(!ok(puzzle[pos][5-face], puzzle[s][face])){
					f = false;
				}
			}
			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(1){
		string str;
		for(int i = 0 ; i < 8 ; i++){
			if(cin >> str , str == "0") return 0;
			data[i] = str;
			used[i] = 0;
		}

		cout << (backTrack(0)?"YES":"NO") << endl;
	}
}