#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <limits>
using namespace std;
typedef long long ll;

enum Face {
	C1, C2, C3, C4, C5, C6, FACE_SIZE
};

struct Dice {
	char face[FACE_SIZE];

	Dice(){}
	Dice(string init){
		for(int i=0;i<FACE_SIZE;i++)face[i] = init[i];
	}

	void roll_y(){
		roll(C2, C3, C5, C4);
	}

	void roll_x(){
		roll(C2, C6, C5, C1);
	}

	void roll_z(){
		roll(C1, C3, C6, C4);
	}

	void roll(Face a, Face b, Face c, Face d){
		char tmp = face[d];
		face[d] = face[c];
		face[c] = face[b];
		face[b] = face[a];
		face[a] = tmp;
	}

	inline char at(int a) const {
		return face[a];
	}
};


int dx[] =  {0, 0,  1, -1, 0, 0};
int dy[] =  {1, -1, 0,  0, 0, 0};
int dz[] =  {0, 0,  0,  0, 1, -1};

Face from[] = {C6, C1, C3, C4, C5, C2};
Face to[] =   {C1, C6, C4, C3, C2, C5};

Dice cube[2][2][2];

inline bool valid(char a, char b){
	if(tolower(a) != tolower(b))return false;
	if(a == b)return false;
	return true;
}

inline bool valid(){
	for(int z=0;z<2;z++)for(int y=0;y<2;y++)for(int x=0;x<2;x++){
		Dice dice = cube[z][y][x];

		vector< int > allow(64, 0);
		int id = 0;
		int cnt = 0;

		for(int kz=0;kz<4;kz++, dice.roll_z())
		for(int ky=0;ky<4;ky++, dice.roll_y())
		for(int kx=0;kx<4;kx++, dice.roll_x()){
			bool ok = true;

			for(int k=0;k<6;k++){
				int nz = z + dz[k];
			    int ny = y + dy[k];
				int nx = x + dx[k];
				if(nz < 0 || nz >= 2 || ny < 0 || ny >= 2 || nx < 0 || nx >= 2)continue;

				char from_face = dice.at(from[k]);
				bool check = false;

				for(int face=0;face<FACE_SIZE;face++){
					if(valid(from_face, cube[nz][ny][nx].at(face))){
						check = true;
						break;
					}
				}

				if(!check){
					ok = false;
					break;
				}
			}

			if(ok){
				allow[id] = true;
				++cnt;
			}

			++id;
		}
		if(cnt == 0)return false;
	}

	return true;
}

string solve(const vector<Dice> &dices){
	vector<int> perm(dices.size());
	for(int i=0;i<perm.size();i++)perm[i] = i;

	do {
		for(int z=0;z<2;z++)for(int y=0;y<2;y++)for(int x=0;x<2;x++){
			int id = (z * 2 + y) * 2 + x;
			cube[z][y][x] = dices[perm[id]];
		}
		if(valid())return "YES";
	} while(next_permutation(perm.begin(), perm.end()));

	return "NO";
}

int main(){
	string init;
	while(cin >> init){
		if(init == "0")break;

		vector<Dice> dices;
		dices.push_back(Dice(init));

		for(int t=0;t<7;t++){
			cin >> init;
			dices.push_back(Dice(init));
		}

		cout << solve(dices) << endl;
	}

	return 0;
}