#include <iostream>
#include <string>
#include <vector>
using namespace std;

enum{
	T, F, R, Ba, L, Bo
};

const char* pattern[ 24 ] =
{
	/*
	"012345", "023415", "034125", "041235",
	"104523", "145203", "152043", "120453",
	"201534", "215304", "253014", "230154",
	"302541", "325401", "354021", "340251",
	"403512", "435102", "451032", "410352",
	"514320", "543210", "532140", "521430",
	*/
	"012435", "024315", "043125", "031245",
	"103524", "135204", "152034", "120354",
	"201543", "215403", "254013", "240153",
	"304512", "345102", "351042", "310452",
	"402531", "425301", "453021", "430251",
	"513420", "534210", "542130", "521340",
};

const int contact[ 8 ][ 6 ] =
{
	{ -1, -1, -1, -1, -1, -1 },
	{ -1, -1, 0, -1, -1, -1 },
	{ -1, -1, -1, 0, -1, -1 },
	{ -1, -1, 2, 1, -1, -1 },
	{ 0, -1, -1, -1, -1, -1 },
	{ 1, -1, -1, 4, -1, -1 },
	{ 2, -1, -1, -1, 4, -1 },
	{ 3, -1, -1, 6, 5, -1 },
};

const int touch[] =
{
	Bo, Ba, L, F, R, T,
};

bool rec( vector< string >& dice, vector< pair< int, int > >& put, int n, int selected )
{
	if( n == 8 ){
		return true;
	}

	int offset = 'a' - 'A';
	for( int i = 0; i < 8; ++i ){
		if( selected & ( 1 << i ) ){
			continue;
		}
		for( int j = 0; j < 24; ++j ){
			put.push_back( make_pair( i, j ) );
			bool miss = false;
			for( int k = 0; k < 6; ++k ){
				int pos = contact[ n ][ k ];
				if( pos >= 0 ){
					char c1 = dice[ i ][ pattern[ j ][ k ] - '0' ];
					char c2 = dice[ put[ pos ].first ][ pattern[ put[ pos ].second ][ touch[ k ] ] - '0' ];
					if( c1 > c2 ){
						c1 -= offset;
					}else{
						c2 -= offset;
					}
					if( c1 != c2 ){
						miss = true;
						break;
					}
				}
			}
			if( !miss && rec( dice, put, n + 1, selected | ( 1 << i ) ) ){
				return true;
			}
			put.pop_back();
		}
	}

	return false;
}

string solve( vector< string >& dice )
{
	vector< pair< int, int > > put;
	if( rec( dice, put, 0, 0 ) ){
		return "YES";
	}
	return "NO";
}

int main()
{
	string s;
	while( cin >> s && s != "0" ){
		vector< string > dice;
		dice.push_back( s );
		for( int i = 0; i < 8 - 1; ++i ){
			cin >> s;
			dice.push_back( s );
		}

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

	return 0;
}