#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;

struct dice {
	char data[7];
	int a = 0, b = 1, c = 2;
	void roll(int x) {
		if (x == 0)swap(a, c), a = 5 - a;
		if (x == 1)swap(a, b), a = 5 - a;
		if (x == 2)swap(b, c), b = 5 - b;
	}
};
dice d[8], a[2][2][2];
int dx[]{ 1,-1,0,0,0,0 }, dy[]{ 0,0,1,-1,0,0 }, dz[]{ 0,0,0,0,1,-1 };
bool ok(int x, int y, int z, int p) {
	rep(i, 6) {
		int nx = x + dx[i], ny = y + dy[i], nz = z + dz[i];
		if (nx < 0 || 2 <= nx || ny < 0 || 2 <= ny || nz < 0 || 2 <= nz || !a[nx][ny][nz].data[0])continue;
		dice c = a[nx][ny][nz];
		if (i == 0 && abs(d[p].data[d[p].a] - c.data[5 - c.a]) != 'a' - 'A')return false;
		if (i == 1 && abs(d[p].data[5 - d[p].a] - c.data[c.a]) != 'a' - 'A')return false;
		if (i == 2 && abs(d[p].data[d[p].b] - c.data[5 - c.b]) != 'a' - 'A')return false;
		if (i == 3 && abs(d[p].data[5 - d[p].b] - c.data[c.b]) != 'a' - 'A')return false;
		if (i == 4 && abs(d[p].data[d[p].c] - c.data[5 - c.c]) != 'a' - 'A')return false;
		if (i == 5 && abs(d[p].data[5 - d[p].c] - c.data[c.c]) != 'a' - 'A')return false;
	}
	return true;
}
bool dfs(int p) {
	if (p == 8)return true;
	rep(i, 2)rep(j, 2)rep(k, 2) {
		if (a[i][j][k].data[0])continue;
		rep(t, 4) {
			rep(l, 4) {
				if (ok(i, j, k, p)) {
					a[i][j][k] = d[p];
					if (dfs(p + 1))return true;
					a[i][j][k].data[0] = 0;
				}
				d[p].roll(0);
			}
			d[p].roll(1);
		}
		d[p].roll(2);
		rep(t, 4) {
			if (ok(i, j, k, p)) {
				a[i][j][k] = d[p];
				if (dfs(p + 1))return true;
				a[i][j][k].data[0] = 0;
			}
			d[p].roll(0);
		}
	}
	return false;
}
int main() {
	while (1) {
		rep(i, 8) {
			scanf("%s", d[i].data);
			if (d[i].data[0] == '0')return 0;
		}
		rep(i, 2)rep(j, 2)rep(k, 2)a[i][j][k].data[0] = 0;
		puts(dfs(0) ? "YES" : "NO");
	}
}