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 <string>
#include <algorithm>
using namespace std;

// s[0] := top,   s[1] := front 
// s[2] := right, s[3] := left
// s[4] := back,  s[5] := bottom
enum{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"
};

// cube[0..7] := サイコロの状態 string が返ってくる.(入力)
string cube[8];
// used[i] := cube[i] を使ったかどうか
bool used[8];
// s[k][pos] := 位置 pos のダイスの k 番目の文字が返ってくる.
char s[6][8];
// 解
bool ans;

// c1, c2 が同じアルファベットで片方が小文字, もう片方が大文字なら true を返す.
bool check(char c1, char c2){
	return (abs(c1-c2) == 32);
}

// s := いままでの使ったサイコロの状態, pos := 位置(0..7)
void dfs(int pos){
	if( ans ) return;
	if( pos == 8 ){
		ans = true;
		return;
	}
	
	for(int i=0 ; i < 8 ; i++ ){
		if( !used[i] ){
			for(int j=0 ; j < 24 ; j++ ){
				
				for(int k = 0 ; k < 6 ; k++ ){
					s[k][pos] = cube[i][list[j][k]-'0'];
				}
				
				used[i] = true;
				if( pos == 0 ){
					dfs(pos+1);
				}else if( pos == 1 ){
					if( check(s[RIGHT][0],s[LEFT][1]) ){
						dfs(pos+1);
					}
				}else if( pos == 2 ){
					if( check(s[FRONT][0],s[BACK][2]) ){
						dfs(pos+1);
					}
				}else if( pos == 3 ){
					if( check(s[RIGHT][2],s[LEFT][3]) && check(s[FRONT][1],s[BACK][3]) ){
						dfs(pos+1);
					}
				}else if( pos == 4 ){
					if( check(s[BOTTOM][0],s[TOP][4]) ){
						dfs(pos+1);
					}
				}else if( pos == 5 ){
					if( check(s[BOTTOM][1],s[TOP][5]) && check(s[RIGHT][4],s[LEFT][5]) ){
						dfs(pos+1);
					}
				}else if( pos == 6 ){
					if( check(s[BOTTOM][2],s[TOP][6]) && check(s[FRONT][4],s[BACK][6]) ){
						dfs(pos+1);
					}
				}else if( pos == 7 ){
					if( check(s[BOTTOM][3],s[TOP][7]) && check(s[FRONT][5],s[BACK][7]) && check(s[RIGHT][6],s[LEFT][7]) ){
						dfs(pos+1);
						return;
					}
				}
				used[i] = false;
			}
		}
	}
}

int main(){
	string s_;
	while( cin >> s_ , s_ != "0" ){
		// 初期化
		ans = false;
		cube[0] = s_;
		for(int i=0 ; i < 8 ; i++ ) used[i] = false;
		
		for(int i=1 ; i < 8 ; i++ ){
			cin >> cube[i];
		}
		dfs(0);
		cout << (ans? "YES" : "NO") << endl;
	}
}