#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

string pat[24] =
{
    "123","135","154","142",
    "231","214","246","263",
    "326","365","351","312",
    "421","415","456","462",
    "513","536","564","541",
    "624","645","653","632"
};

string dice[8];
bool used[8];
int sel[8];
int num[8];

bool check(int d1, int pos1, int d2, int pos2) {
    char c1 = dice[sel[d1]][pat[num[d1]][pos1 - 1] - '1'];
    char c2 = dice[sel[d2]][pat[num[d2]][pos2 - 1] - '1'];
    return c1 != c2 && (c1 - 32 == c2 || c2 - 32 == c1);
}

bool dfs(int p) {
    if (p == 8) return true;

    REP(i, 8) if (!used[i]) {
        used[i] = true;
        sel[p] = i;
        REP(j, 24) {
            num[p] = j;
            bool flag = false;
            switch (p) {
                case 0: flag = true; break;
                case 1: if (check(0, 3, 1, 4)) flag = true; break;
                case 2: if (check(0, 2, 2, 5)) flag = true; break;
                case 3: if (check(1, 2, 3, 5) && check(2, 3, 3, 4)) flag = true; break;
                case 4: if (check(0, 6, 4, 1)) flag = true; break;
                case 5: if (check(1, 6, 5, 1) && check(4, 3, 5, 4)) flag = true; break;
                case 6: if (check(4, 2, 6, 5) && check(2, 6, 6, 1)) flag = true; break;
                case 7: if (check(6, 3, 7, 4) && check(5, 2, 7, 5) && check(3, 6, 7, 1)) flag = true; break;
            }
            if (flag && dfs(p + 1)) return true;
        }
        used[i] = false;
    }
    return false;
}

int main() {
/*	123456
	135246
	154326
	142536
	231645
	214365
	246135
	263415
	326154
	365214
	351624
	312564
	421653
	415263
	456123
	462513
	513462
	536142
	564312
	541632
	624351
	645231
	653421
	632541*/ 
	
    REP(i, 24) {
        for (int j = 2; j >= 0; j--) pat[i] += (7 - (pat[i][j] - '0')) + '0';
    }


    while (cin >> dice[0]) {
        if (dice[0] == "0") break;

        FOR(i, 1, 8) cin >> dice[i];

        memset(used, 0, sizeof(used));

        if (dfs(0)) puts("YES");
        else puts("NO");
    }
    return 0;
}