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