import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

string rotX(in string s) {
    return [s[0], s[3], s[1], s[4], s[2], s[5]];
}

string rotY(in string s) {
    return [s[2], s[1], s[5], s[0], s[4], s[3]];
}

string rotZ(in string s) {
    return [s[4], s[0], s[2], s[3], s[5], s[1]];
}

bool test2(string[] s) {
    foreach(i; iota(4)) {
        foreach(j; iota(4)) {
            if(test3(s)) {
                return true;
            }
            s[0] = rotX(s[0]);
        }
        s[0] = rotY(s[0]);
    }
    s[0] = rotZ(s[0]);
    foreach(i; iota(4)) {
        if(test3(s)) {
            return true;
        }
        s[0] = rotX(s[0]);
    }
    s[0] = rotZ(rotZ(s[0]));
    foreach(i; iota(4)) {
        if(test3(s)) {
            return true;
        }
        s[0] = rotX(s[0]);
    }
    return false;
}

bool test3(string[] s) {
    auto t1 = test4(s[1], s[0][1]);
    if(!t1[0]) {
        return false;
    }
    s[1] = rotZ(rotZ(rotZ(t1[1])));
    auto t2 = test4(s[3], s[0][5]);
    if(!t2[0]) {
        return false;
    }
    s[3] = t2[1];
    auto t3 = test4(s[4], s[0][3]);
    if(!t3[0]) {
        return false;
    }
    s[4] = rotY(rotY(rotY(t3[1])));
    foreach(i; iota(4)) {
        foreach(j; iota(4)) {
            foreach(k; iota(4)) {
                auto t4 = test5(s[2], s[1][5], s[3][1]);
                auto t5 = test5(s[5], s[1][3], s[4][1]);
                auto t6 = test5(s[7], s[3][3], s[4][5]);
                if(t4[0] && t5[0] && t6[0]) {
                    auto t7 = test5(s[6], t4[1][2], t5[1][3]);
                    if(t7[0] && t7[1][3] == t6[1][2].reverseCase()) {
                        return true;
                    }
                }
                s[4] = rotZ(s[4]);
            }
            s[3] = rotX(s[3]);
        }
        s[1] = rotY(s[1]);
    }
    return false;
}

dchar reverseCase(dchar c) {
    if(c.isUpper()) {
        return std.ascii.toLower(c);
    } else {
        return std.ascii.toUpper(c);
    }
}

auto test4(string s, dchar c) {
    c = reverseCase(c);
    if(s[0] == c) {
        return tuple(true, s);
    }
    if(s[1] == c) {
        return tuple(true, rotY(rotX(s)));
    }
    if(s[2] == c) {
        return tuple(true, rotY(s));
    }
    if(s[3] == c) {
        return tuple(true, rotY(rotY(rotY(s))));
    }
    if(s[4] == c) {
        return tuple(true, rotZ(s));
    }
    if(s[5] == c) {
        return tuple(true, rotY(rotY(s)));
    }
    return tuple(false, s);
}
auto test5(string s, dchar c1, dchar c2) {
    if(c1 == c2) {
        return tuple(false, s);
    }
    c1 = reverseCase(c1);
    c2 = reverseCase(c2);
    if(!s.canFind(c1) || !s.canFind(c2)) {
        return tuple(false, s);
    }
    auto n1 = s.until(c1).count;
    auto n2 = s.until(c2).count;
    if(n1 + n2 == 5) {
        return tuple(false, s);
    }
    final switch(n1) {
        case 0:
            break;
        case 1:
            s = rotY(rotX(s));
            break;
        case 2:
            s = rotY(s);
            break;
        case 3:
            s = rotY(rotY(rotY(s)));
            break;
        case 4:
            s = rotZ(s);
            break;
        case 5:
            s = rotZ(rotZ(s));
            break;
    }
    n2 = s.until(c2).count;
    final switch(n2) {
        case 1:
            break;
        case 2:
            s = rotX(rotX(rotX(s)));
            break;
        case 3:
            s = rotX(s);
            break;
        case 4:
            s = rotX(rotX(s));
            break;
    }
    return tuple(true, s);
}

bool test(string[] s, int n) {
    if(n == s.length) {
        return test2(s);
    }
    foreach(i; iota(n, s.length)) {
        swap(s[n], s[i]);
        if(test(s, n+1)) {
            return true;
        }
        swap(s[n], s[i]);
    }
    return false;
}


void main() {
    while(true) {
        string[] s;
        s ~= readln().chomp();
        if(s[0] == "0") {
            return;
        }
        foreach(i; iota(1, 8)) {
            s ~= readln().chomp();
        }
        writeln(test(s, 1) ? "YES": "NO");
    }
}