import std.stdio;
import std.c.stdlib;
import std.c.string;
import core.stdc.ctype;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;


enum { TOP, FRONT, RIGHT, LEFT, BACK, BOTTOM }
class Dice {
    char v[6];
    this() {}
    this(string s) {
        foreach (i; 0 .. 6) {
            v[i] = s[i];
        }
    }
    override bool opEquals(Object o) const {
        Dice d = cast(Dice)o;
        foreach (i; 0 .. 6) {
            if (v[i] != d.v[i]) return false;
        }
        return true;
    }
    void rollX() { roll(TOP, FRONT, BOTTOM, BACK); }
    void rollY() { roll(TOP, LEFT, BOTTOM, RIGHT); }
    void rollZ() { roll(FRONT, RIGHT, BACK, LEFT); }
    void roll() (int a, int b, int c, int d) {
        char t = v[a];
        v[a] = v[b]; v[b] = v[c]; v[c] = v[d]; v[d] = t;
    }
    Dice dup() const {
        Dice ret = new Dice;
        foreach (i; 0 .. 6) {
            ret.v[i] = v[i];
        }
        return ret;
    }
    Dice[] allState() const {
        Dice[] Ret;
        Dice d = this.dup;
        foreach (i; 0 .. 6) {
            if (i % 2 == 0) d.rollX();
            else            d.rollY();
            foreach (j; 0 .. 4) {
                d.rollZ();
                Ret ~= d.dup;
            }
        }
        return Ret;
    }
    bool isSameDice(in Dice d) const {
        Dice[] states = allState;
        return states.any!((a) => a == d);
    }
    override string toString() const {
        return "Dice: " ~ v.to!string;
    }
}
 
void main() {
    const z = [ [], [0], [0], [1, 2],
                [0], [1, 4], [2, 4], [3, 5, 6] ];
    const f = [ [], [RIGHT], [FRONT], [FRONT, RIGHT],
                [BOTTOM], [BOTTOM, RIGHT], [BOTTOM, FRONT], [BOTTOM, FRONT, RIGHT] ];
    const t = [
        TOP: BOTTOM,
        FRONT: BACK,
        RIGHT: LEFT,
        LEFT: RIGHT,
        BACK: FRONT,
        BOTTOM: TOP
    ];
    Dice[] F = new Dice[8];
    Dice[][] states = new Dice[][8];
    bool input() {
        string s = readln.chomp;
        if (s == "0") return false;
        F[0] = new Dice(s);
        foreach (i; 1 .. 8) {
            F[i] = new Dice(readln.chomp);
        }
        foreach (i; 0 .. 8) states[i] = F[i].allState;
        return true;
    }

    void solve() {
        bool[] used = new bool[8];
        char flip(char c) {
            if (c.islower) return cast(char)(c.toupper);
            else return cast(char)(c.tolower);
        }
        bool dfs(int index, ref Dice[] x) {
            //writeln(index);
            if (index == 8) return true;
            foreach (i; 0 .. 8) {
                if (used[i]) continue;
                //foreach (state; F[i].allState) {
                foreach (state; states[i]) {
                    foreach (k, j; z[index]) {
                        int face = f[index][k];
                        /*
                        writeln([index, k, j, face]);
                        writeln(x[j]);
                        writeln(x[j].v[face]);
                        writeln(state.v[t[face]]);
                        writeln(flip(state.v[t[face]]));
                        */
                        if (x[j].v[face] == flip(state.v[t[face]])) continue;
                        goto nextState;
                    }

                    used[i] = true;
                    x[index] = state;
                    if (dfs(index + 1, x)) return true;
                    used[i] = false;

                    nextState:;
                }
            }
            return false;
        }
        auto ds = new Dice[8];
        writeln(dfs(0, ds) ? "YES" : "NO");
    }

    while (input) solve;
}

Measured memory_bytes: 1236