# define _CRT_SECUREj_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }


struct dice
{
	string o;
	vs a;
	dice(string _a)
	{
		o = _a;
		init();
	}
	string & operator[](int n) { return a[n]; }

	void init()
	{
		string s;
		int d[6][10] = { {-1},{1,-1},{0,0,0,1,-1},{0,1,-1},{0,0,1,-1},{1,1,-1} };
		FOR(i, 6)
		{
			s = o;
			FOR(j, 10)
			{
				if (d[i][j] == -1)break;
				if (d[i][j] == 1)sn(s);
				else se(s);
			}
			FOR(j, 4)
			{
				a.push_back(s);
				se(s);
			}
		}
	}

	void sn(string &s)
	{
		swap(s[1], s[5]);
		swap(s[2], s[1]);
		swap(s[6], s[2]);
	}
	void se(string &s)
	{
		swap(s[2], s[3]);
		swap(s[4], s[2]);
		swap(s[5], s[4]);
	}
};
vector<dice> a;
bool hoge(char c1, char c2)
{
	int l = 0;
	if (islower(c1))l++;
	if (islower(c2))l++;
	if (l != 1||tolower(c1)!=tolower(c2))return false;
	return true;
}
bool check(vs &v)
{
	bool ans = true;
	switch (v.size())
	{
	case 0:
		break;
	case 1:
		break;
	case 2:
		if (!hoge(v[0][3], v[1][4]))ans = false;
		break;
	case 3:
		if (!hoge(v[0][5], v[2][2]))ans = false;
		break;
	case 4:
		if (!hoge(v[1][5], v[3][2]))ans = false;
		if (!hoge(v[2][3], v[3][4]))ans = false;
		break;
	case 5:
		if (!hoge(v[0][6], v[4][1]))ans = false;
		break;
	case 6:
		if (!hoge(v[1][6], v[5][1]))ans = false;
		if (!hoge(v[4][3], v[5][4]))ans = false;
		break;
	case 7:
		if (!hoge(v[2][6], v[6][1]))ans = false;
		if (!hoge(v[4][5], v[6][2]))ans = false;
		break;
	case 8:
		if (!hoge(v[3][6], v[7][1]))ans = false;
		if (!hoge(v[5][5], v[7][2]))ans = false;
		if (!hoge(v[6][3], v[7][4]))ans = false;
		break;
	}
	return ans;
}

int calc(vs &v,int bit)
{
	int n = v.size();
	if (check(v) == false)return 0;
	if (n == 8)return 1;
	int ans = 0;
	FOR(i, 8)
	{
		if (bit & 1 << i)continue;
		FOR(j, 24)
		{
			v.push_back(a[i][j]);
			ans+=calc(v, bit | 1 << i);
			v.pop_back();
		}
	}
	return ans;
}
int main()
{
	while(1)
	{
		a.clear();
		FOR(i, 8)
		{
			string s;
			cin >> s;
			if (s == "0")return 0;
			s.insert(s.begin(), ' ');
			a.push_back(dice(s));
		}
		vs v;
		cout << (calc(v,0) ? "YES" : "NO") << endl;
	}
}