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;
string t[2][2][2];
string u[192];
bool used[8];
int n,flg;

int checkch='A'-'a';

bool input();
string ra(string,int);
string rb(string,int);
string rc(string,int);
void dfs(int,int,int);

inline bool check_ch(char x,char y){
  return (x+checkch==y||x-checkch==y);
}
inline bool check_x(string a,string b){
  return check_ch(a[2],b[3]);
}
inline bool check_y(string a,string b){
  return check_ch(a[4],b[1]);
}
inline bool check_z(string a,string b){
  return check_ch(a[0],b[5]);
}


int main(){

  while(input()){
    for(int i=0;i<8;i++)used[i]=false;
    
    flg=0;
    dfs(0,0,0);
    if(flg)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
  return 0;
}

void dfs(int x,int y,int z){
  //cout<<x<<' '<<y<<' '<<z<<endl;
  if(x==2){x=0;y++;}
  if(y==2){y=0;z++;}
  if(x==0&&y==0&&z==2)flg=1;

  for(int j=0;j<8;j++){
    if(used[j])continue;
    for(int i=j*24;i<j*24+24;i++){
      if(flg)return;
      if(x>0)if(check_ch(t[x-1][y][z][2],u[i][3])==false)continue;
      if(y>0)if(check_ch(t[x][y-1][z][4],u[i][1])==false)continue;
      if(z>0)if(check_ch(t[x][y][z-1][0],u[i][5])==false)continue;
      /*
      if(x>0)if(check_x(t[x-1][y][z],u[i])==false)continue;
      if(y>0)if(check_y(t[x][y-1][z],u[i])==false)continue;
      if(z>0)if(check_z(t[x][y][z-1],u[i])==false)continue;
      */
      used[j]=true;
      t[x][y][z]=u[i];
      dfs(x+1,y,z);
      used[j]=false;
    }
  }
}



bool input(){
  string in,str,str2;
  n=0;
  for(int i=0;i<8;i++){
    cin>>in;if(in=="0")return false;
    for(int j=0;j<6;j++){
      if(j<4)str=ra(in,j);
      else if(j==4)str=rb(in,1);
      else str=rb(in,3);
      for(int k=0;k<4;k++){
	str2=rc(str,k);
	u[n++]=str2;
      }
    }
    
  }
  return true;
}

string ra(string str,int x){
  char tmp;
  for(int i=0;i<x;i++){
    tmp=str[3];
    str[3]=str[0];
    str[0]=str[2];
    str[2]=str[5];
    str[5]=tmp;
  }
  return str;
}
string rb(string str,int x){
  char tmp;
  for(int i=0;i<x;i++){
    tmp=str[5];
    str[5]=str[4];
    str[4]=str[0];
    str[0]=str[1];
    str[1]=tmp;
  }
  return str;
}
string rc(string str,int x){
  char tmp;
  for(int i=0;i<x;i++){
    tmp=str[1];
    str[1]=str[2];
    str[2]=str[4];
    str[4]=str[3];
    str[3]=tmp;
  }
  return str;
}