#include <iostream>
#include <utility>
#include <vector>
#include <cctype>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;

int dice_dir[24][6] = {
	{0, 1, 2, 3, 4, 5},
	{0, 3, 1, 4, 2, 5},
	{0, 4, 3, 2, 1, 5},
	{0, 2, 4, 1, 3, 5},

	{5, 3, 4, 1, 2, 0},
	{5, 1, 3, 2, 4, 0},
	{5, 2, 1, 4, 3, 0},
	{5, 4, 2, 3, 1, 0},

	{1, 2, 0, 5, 3, 4},
	{1, 5, 2, 3, 0, 4},
	{1, 3, 5, 0, 2, 4},
	{1, 0, 3, 2, 5, 4},

	{4, 5, 3, 2, 0, 1},
	{4, 2, 5, 0, 3, 1},
	{4, 0, 2, 3, 5, 1},
	{4, 3, 0, 5, 2, 1},

	{2, 0, 1, 4, 5, 3},
	{2, 4, 0, 5, 1, 3},
	{2, 5, 4, 1, 0, 3},
	{2, 1, 5, 0, 4, 3},

	{3, 4, 5, 0, 1, 2},
	{3, 0, 4, 1, 5, 2},
	{3, 1, 0, 5, 4, 2},
	{3, 5, 1, 4, 0, 2},
};

typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;

vector<vpii> constraint;

void init_constraint() {
	for(int i = 0; i < 8; i++)
		constraint.push_back(vpii());
	constraint[1].push_back(pii(0,4));
	constraint[2].push_back(pii(1,3));
	constraint[3].push_back(pii(2,1));
	constraint[3].push_back(pii(0,3));
	constraint[4].push_back(pii(0,5));
	constraint[5].push_back(pii(1,5));
	constraint[5].push_back(pii(4,4));
	constraint[6].push_back(pii(2,5));
	constraint[6].push_back(pii(5,3));
	constraint[7].push_back(pii(3,5));
	constraint[7].push_back(pii(6,1));
	constraint[7].push_back(pii(4,3));
}

int use = 0;
pair<int,int> dice_per[8];
char dice_char[16][16];

bool search(int num) {
	if(num >= 8)
		return true;

	for(int d = 0; d < (num == 0 ? 1 : 8); d++) {
		if(!(use & (1 << d))) {
			use |= (1 << d);

			for(int i = 0; i < 24; i++) {
				bool flg = true;
				for(int j = 0; j < constraint[num].size(); j++) {
					char ca, cb;
					ca = dice_char[                   d                    ][dice_dir[                    i                    ][5 - constraint[num][j].second]];
					cb = dice_char[dice_per[constraint[num][j].first].first][dice_dir[dice_per[constraint[num][j].first].second][    constraint[num][j].second]];

					flg &= (tolower(ca) == tolower(cb)) && (abs(ca - cb) == abs('A' - 'a'));
				}
				if(flg) {
					dice_per[num] = pii(d, i);
					if(search(num + 1))
						return true;
				}
			}

			use &= ~(1 << d);
		}
	}

	return false;
}

int main() {
	init_constraint();

	while(1) {
		use = 0;
		for(int i = 0; i < 8; i++) {
			scanf("%s", dice_char[i]);
			if(dice_char[i][0] == '0')
				goto EXIT;
		}

		cout << (search(0) ? "YES" : "NO") << endl;
	}
EXIT:;
}