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:
#define _USE_MATH_DEFINES
#include <iostream>
#include <memory>
#include <memory.h>
#include <fstream>
#include <cmath>
#include <math.h>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

bool ok;
string s[8];
int nums[24][3] = {
	{0, 1, 3}, {0, 3, 4}, {0, 4, 2}, {0, 2, 1},
	{1, 5, 3}, {1, 3, 0}, {1, 0, 2}, {1, 2, 5},
	{2, 1, 0}, {2, 0, 4}, {2, 4, 5}, {2, 5, 1},
	{3, 1, 5}, {3, 5, 4}, {3, 4, 0}, {3, 0, 1},
	{4, 0, 3}, {4, 3, 5}, {4, 5, 2}, {4, 2, 0},
	{5, 1, 2}, {5, 2, 4}, {5, 4, 3}, {5, 3, 1},
};
char dices[4][4][4][6];

bool dfs(int state, int n){
	if(ok) return true;
	bool res = false;
	if(n == 8){
		ok = true;
		return true;
	}
	if(n == 0){
		rep(i, 24){
			dices[1][1][1][3] = s[0][5-nums[i][0]];
			dices[1][1][1][4] = s[0][5-nums[i][1]];
			dices[1][1][1][5] = s[0][5-nums[i][2]];
			res |= dfs(1, 1);
			dices[1][1][1][3] = '*';
			dices[1][1][1][4] = '*';
			dices[1][1][1][5] = '*';
		}	
		
	}else{
		int z = n / 4 + 1;
		int y = (n % 4) / 2 + 1;
		int x = n % 2 + 1;
		rep(i, 8){
			if(state & (1 << i)) continue;
			rep(j, 24){
				bool f1 = (dices[x][y][z-1][3] == '*' ||
					abs(dices[x][y][z-1][3] - s[i][nums[j][0]]) == 32);
				bool f2 = (dices[x][y-1][z][4] == '*' || 
					abs(dices[x][y-1][z][4] - s[i][nums[j][1]]) == 32);
				bool f3 = (dices[x-1][y][z][5] == '*' ||
					abs(dices[x-1][y][z][5] - s[i][nums[j][2]]) == 32);
				if(f1 && f2 && f3){
					dices[x][y][z][3] = s[i][5-nums[j][0]];
					dices[x][y][z][4] = s[i][5-nums[j][1]];
					dices[x][y][z][5] = s[i][5-nums[j][2]];
					res |= dfs(state | 1 << i, n + 1);
					dices[x][y][z][3] = '*';
					dices[x][y][z][4] = '*';
					dices[x][y][z][5] = '*';
				}
			}
		}
	}
	return res;
}

int main(){
	while(cin >> s[0] && s[0] != "0"){
		ok = false;
		rep2(i, 1, 8) cin >> s[i];
		fill(&dices[0][0][0][0], &dices[0][0][0][0]+4*4*4*6, '*');
		if(dfs(0, 0)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}