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<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;
typedef stringstream SS;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
SS ss;
#define debug ss
#endif

template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repnd(i,m,n) for(int i=(n);i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repnd0(i,m,n) for(i=(n);i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int dx[]={1,-1,0,0,1,-1,1,-1,0};
const int dy[]={0,0,1,-1,1,-1,-1,1,0};

string dice[8];
string rotdice[8][24];
string sdice[8];
bool used[8];

bool val(int pos){
	int x=pos%2,y=pos/2%2,z=pos/4%2;
//if(x==1)cout<<pos<<" "<<sdice[pos]<<" "<<sdice[pos-1]<<" "<<abs(sdice[pos][3]-sdice[pos-1][2])<<endl;
//if(y==1)cout<<pos<<" "<<sdice[pos]<<" "<<sdice[pos-2]<<" "<<abs(sdice[pos][4]-sdice[pos-2][1])<<endl;
//if(z==1)cout<<pos<<" "<<sdice[pos]<<" "<<sdice[pos-4]<<" "<<abs(sdice[pos][5]-sdice[pos-4][0])<<endl;
	if(x==1&&abs(sdice[pos][3]-sdice[pos-1][2])!=32)return false;
	if(y==1&&abs(sdice[pos][4]-sdice[pos-2][1])!=32)return false;
	if(z==1&&abs(sdice[pos][5]-sdice[pos-4][0])!=32)return false;
	return true;
}

string h(string s,int n){
	if(n==0)return s;
	string ss;
	ss+=s[0];
	ss+=s[3];
	ss+=s[1];
	ss+=s[4];
	ss+=s[2];
	ss+=s[5];
	return h(ss,n-1);
}

string g(string s,int n){
	int pos[6][6]={
		{0,1,2,3,4,5},
		{1,5,2,3,0,4},
		{2,1,5,0,4,3},
		{3,1,0,5,4,2},
		{4,0,2,3,5,1},
		{5,4,2,3,1,0},
	};
	string res;
	rep(i,6)res+=s[pos[n][i]];
	return res;
}

bool f(int pos){
	if(pos==8){return true;}
	rep(k,8){
		if(pos==0&&k>0)break;
		if(used[k])continue;
		used[k]=true;
		rep(i,24){
			sdice[pos]=rotdice[k][i];
			if(!val(pos))continue;
			if(f(pos+1))return true;
		}
		used[k]=false;
	}
	return false;
}

int main() {
	IL{
		cin>>dice[0];
		if(dice[0]=="0")break;
		rep(i,7)cin>>dice[i+1];
		rep(i,8)used[i]=false;
		rep(k,8){
			rep(i,6){
				string d=g(dice[k],i);
				rep(j,4){
					rotdice[k][i*4+j]=h(d,j);
				}
			}
		}
		if(f(0)){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}