#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;
}


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;
}