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 <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define mp make_pair
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e10,EPS=1e-9;

char in[8][7],pat[192][7];
int d[8];
bool use[8];

void rot(int nm,int xyz)
{
	char *s=in[nm],t;
	if(xyz==0)
	{
		t=s[1]; s[1]=s[2]; s[2]=s[4];
		s[4]=s[3]; s[3]=t; return;
	}
	if(xyz==1)
	{
		t=s[0]; s[0]=s[1]; s[1]=s[5];
		s[5]=s[4]; s[4]=t; return;
	}
	t=s[0]; s[0]=s[2]; s[2]=s[5];
	s[5]=s[3]; s[3]=t;
}
bool ok(int d1,int f1,int d2,int f2)
{
	d1=d[d1]; d2=d[d2];
	if(d1<0||d2<0)return 1;
	char c1=pat[d1][f1],c2=pat[d2][f2];
	return tolower(c1)==tolower(c2)&&c1!=c2;
}
bool ck()
{
	if(!ok(0,2,1,3)||!ok(0,4,2,1)||//1ツ階ツ督ッツ士
		!ok(2,2,3,3)||!ok(1,4,3,1)||
		!ok(0,0,4,5)||!ok(1,0,5,5)||//1-2ツ階
		!ok(2,0,6,5)||!ok(3,0,7,5)||
		!ok(4,2,5,3)||!ok(4,4,6,1)||//2ツ階ツ督ッツ士
		!ok(6,2,7,3)||!ok(5,4,7,1)
	)return 0;
	return 1;
}
bool dfs(int c)
{
	if(c==8)return 1;
	rep(i,8)if(!use[i])rep(j,24)
	{
		d[c]=i*24+j; use[i]=1;
		if(ck()&&dfs(c+1))return 1;
		d[c]=-1; use[i]=0;
	}
	return 0;
}
int main()
{
	while(scanf("%s",in[0]),in[0][0]!='0')
	{
		rep(i,7)scanf("%s",in+i+1);
		rep(i,8)use[i]=0,d[i]=-1;
		use[0]=1;
		
		int m=0;
		rep(i,8)
		{
			set<string> S;
			rep(x,4)
			{
				rep(y,4)
				{
					rep(z,4)
					{
						S.insert(in[i]);
						rot(i,0);
					}
					rot(i,1);
				}
				rot(i,2);
			}
			fr(it,S)strcpy(pat[m++],it->c_str());
		}
		rep(i,24)
		{
			d[0]=i;
			if(dfs(1))
			{
				puts("YES"); goto END;
			}
		}
		puts("NO"); END:;
	}
	return 0;
}