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

#define TOP 0
#define FRO 1
#define RIGHT 2
#define BACK 3
#define LEFT 4
#define BOTTOM 5
#define ROTATE_R 0
#define ROTATE_F 1
#define DIF 'a'-'A'

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

int r_table[2][6]={
  TOP,LEFT,FRO,RIGHT,BACK,BOTTOM,
  BACK,TOP,RIGHT,BOTTOM,LEFT,FRO
};

int cmp[6]={
  BOTTOM,BACK,LEFT,FRO,RIGHT,TOP
};

bool visited[2][2][2]={false};

typedef struct{char d[7];} Dice;

Dice dice[2][2][2];

void rotate(Dice &in,int flag){
  Dice tmp=in;
  rep(i,6)in.d[i]=tmp.d[r_table[flag][i]];
}

bool check(int x,int y,int z){
  rep(i,6){
    int cx=x+dx[i],cy=y+dy[i],cz=z+dz[i];
    if ( cx<0||cy<0||cx>=2||cy>=2 ||cz<0||cz>=2|| visited[cx][cy][cz]==false)continue;
    int tmp=dice[x][y][z].d[i]-dice[cx][cy][cz].d[cmp[i]];
    if ( tmp == DIF  || -tmp == DIF );
    else return false;
  }
  return true;
}

bool solve(int now,Dice *in,bool *used){
  int x=now%2,y=(now%4)/2,z=now/4;
  if ( now == 8)return true;
  visited[x][y][z]=true;
  rep(k,8){
    if ( used[k] == true)continue;
    rep(i,6){
      if ( i == 4)rep(j,2)rotate(in[k],ROTATE_R);
      if ( i ==5) rep(j,2)rotate(in[k],j);
      rep(i,4){
	rotate(in[k],ROTATE_R);
	dice[x][y][z]=in[k];
	used[k]=true;
	if ( check(x,y,z)  && solve(now+1,in,used) )return true;
	used[k]=false;
      }
      rotate(in[k],ROTATE_F);
    }
  }
  visited[x][y][z]=false;
  return false;
}


int main(){
  Dice in[8];
  while(cin>>in[0].d && in[0].d[0] !='0'){
    rep(i,7)cin>>in[i+1].d;
    rep(i,8)swap(in[i].d[3],in[i].d[4]);
    bool used[8]={false};
    rep(i,2)rep(j,2)rep(k,2)visited[i][j][k]=false;
    if ( solve(0,in,used))puts("YES");
    else puts("NO");
  }
  return false;
}