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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
string s[8];
vector<vector<int> > rot;
void do_rotate(vector<int>& v, int a, int b, int c, int d){
  int t = v[a];
  v[a] = v[b]; v[b] = v[c]; v[c] = v[d]; v[d] = t;
}
void make_rot(){
  vector<int> v(6);
  REP(i, 6) v[i] = i;
  for(int k = 0; k < 6; k++){
    if(k % 2 == 0) do_rotate(v, 0, 2, 5, 3);
    else do_rotate(v, 0, 1, 5, 4);
    for(int l = 0; l < 4; l++){
      do_rotate(v, 1, 2, 4, 3);
      rot.push_back(v);
    }
  }
}
bool used[8];
int d_id[8];
int r_id[8];
// {id1, id2, r1, r2}
int role[12][4] = {
  {0, 1, 2, 3},
  {0, 2, 1, 4},
  {0, 4, 5, 0},
  {1, 3, 1, 4},
  {1, 5, 5, 0},
  {2, 3, 2, 3},
  {2, 6, 5, 0},
  {3, 7, 5, 0},
  {4, 5, 2, 3},
  {4, 6, 1, 4},
  {5, 7, 1, 4},
  {6, 7, 2, 3}
};
bool match(char c, char d){
  if(c > d) swap(c, d);
  return c - 'A' + 'a' == d;
}
bool dfs(int k){
  for(int i = 0; i < 12; i++) if(role[i][1] < k){
    int id1 = role[i][0], id2 = role[i][1];
    int r1 = role[i][2], r2 = role[i][3];
    char c1 = s[d_id[id1]][rot[r_id[id1]][r1]];
    char c2 = s[d_id[id2]][rot[r_id[id2]][r2]];
    if(!match(c1, c2)) return false;
  }
  if(k == 8) return true;
  for(int i = 0; i < 8; i++) if(!used[i]){
    used[i] = true;
    d_id[k] = i;
    for(int j = 0; j < 24; j++){
      r_id[k] = j;
      if(dfs(k + 1)) return true;
    }
    used[i] = false;
  }
  return false;
}
int main(){
  make_rot();
  while(true){
    REP(i, 8) cin >> s[i];
    if(cin.eof()) break;
    memset(used, 0, sizeof used);
    memset(d_id, 0, sizeof d_id);
    memset(r_id, 0, sizeof r_id);
    if(dfs(0)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}