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 RULE[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}
};
vector<int> id1[8];
vector<int> id2[8];
vector<int> r1[8];
vector<int> r2[8];
void make_rule(){
  for(int i = 0; i < 12; i++){
    int x = RULE[i][1];
    id1[x].push_back(RULE[i][0]);
    id2[x].push_back(RULE[i][1]);
    r1[x].push_back(RULE[i][2]);
    r2[x].push_back(RULE[i][3]);
  }
}
bool match(char c, char d){
  if(c > d) swap(c, d);
  return c - 'A' + 'a' == d;
}
bool dfs(int k){
  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;
      bool ok = true;
      for(int i = 0; i < id1[k].size(); i++){
        char c1 = s[d_id[id1[k][i]]][rot[r_id[id1[k][i]]][r1[k][i]]];
        char c2 = s[d_id[id2[k][i]]][rot[r_id[id2[k][i]]][r2[k][i]]];
        if(!match(c1, c2)){
          ok = false;
          break;
        }
      }
      if(ok && dfs(k + 1)) return true;
    }
    used[i] = false;
  }
  return false;
}
int main(){
  make_rot();
  make_rule();
  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;
}