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<string>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++)

class Cube{
    public:
    char f[6];
    Cube(){}
    void roll_z(){ roll(1, 2, 4, 3);}
    void roll_y(){ roll(0, 2, 5, 3);}
    void roll_x(){ roll(0, 1, 5, 4);}
    void roll(int i, int j, int k, int l){
	char t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
    }
};

Cube C[8], D[8];
bool U[8];

bool invalid(char c1, char c2){
    return !( max(c1, c2) - min(c1, c2 ) == 32 );
}

bool rec( int p ){
    if ( p == 8 ) return true;
    rep(a, 8){
	if ( U[a] ) continue;
	Cube c = C[a];
	U[a] = true;
	for ( int i = 0; i < 6; i++, (i%2)?c.roll_x():c.roll_y()){
	    for ( int j = 0; j < 4; j++, c.roll_z()){
		D[p] = c;
		if ( p % 2 && invalid(D[p-1].f[2], D[p].f[3])) continue;
		if ( p > 3 && invalid(D[p-4].f[4], D[p].f[1])) continue;
		if ( p%4 > 1 && invalid(D[p-2].f[5], D[p].f[0])) continue;
		if ( rec(p+1) ) return true;
	    }
	}
	U[a] = false;
    }
    return false;
}

int main(){
    string str;
    while( cin >> str && str != "0" ) {
	rep(s, 6) C[0].f[s] = str[s];
	for ( int i= 1; i < 8; i++ ) { cin >> str; rep(s, 6) C[i].f[s] = str[s]; };
	rep(i, 8) U[i] = false;
	if ( rec(0) ) cout << "YES" << endl;
	else cout << "NO" << endl;
    }
}