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 <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

string pat[24] =
{
    "123","135","154","142",
    "231","214","246","263",
    "326","365","351","312",
    "421","415","456","462",
    "513","536","564","541",
    "624","645","653","632"
};

string dice[8];
bool used[8];
int sel[8];
int num[8];

bool check(int d1, int pos1, int d2, int pos2) {
    char c1 = dice[sel[d1]][pat[num[d1]][pos1 - 1] - '1'];
    char c2 = dice[sel[d2]][pat[num[d2]][pos2 - 1] - '1'];
    return c1 != c2 && (c1 - 32 == c2 || c2 - 32 == c1);
}

bool dfs(int p) {
    if (p == 8) return true;

    REP(i, 8) if (!used[i]) {
        used[i] = true;
        sel[p] = i;
        REP(j, 24) {
            num[p] = j;
            bool flag = false;
            switch (p) {
                case 0: flag = true; break;
                case 1: if (check(0, 3, 1, 4)) flag = true; break;
                case 2: if (check(0, 2, 2, 5)) flag = true; break;
                case 3: if (check(1, 2, 3, 5) && check(2, 3, 3, 4)) flag = true; break;
                case 4: if (check(0, 6, 4, 1)) flag = true; break;
                case 5: if (check(1, 6, 5, 1) && check(4, 3, 5, 4)) flag = true; break;
                case 6: if (check(4, 2, 6, 5) && check(2, 6, 6, 1)) flag = true; break;
                case 7: if (check(6, 3, 7, 4) && check(5, 2, 7, 5) && check(3, 6, 7, 1)) flag = true; break;
            }
            if (flag && dfs(p + 1)) return true;
        }
        used[i] = false;
    }
    return false;
}

int main() {
/*	123456
	135246
	154326
	142536
	231645
	214365
	246135
	263415
	326154
	365214
	351624
	312564
	421653
	415263
	456123
	462513
	513462
	536142
	564312
	541632
	624351
	645231
	653421
	632541*/ 
	
    REP(i, 24) {
        for (int j = 2; j >= 0; j--) pat[i] += (7 - (pat[i][j] - '0')) + '0';
    }


    while (cin >> dice[0]) {
        if (dice[0] == "0") break;

        FOR(i, 1, 8) cin >> dice[i];

        memset(used, 0, sizeof(used));

        if (dfs(0)) puts("YES");
        else puts("NO");
    }
    return 0;
}