using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class State
    {
        internal List<int> root;

        public State()
        {
            root = new List<int>();
        }
    }

    struct Comb { internal string top, btm; }

    class DicePuzzle
    {
        readonly int[][] table;
        readonly int n = 8;

        string[] dices;
        State[,] memo;
        bool[] used;
        int[] path;
        bool isClear;

        List<Comb> S, T;

        public DicePuzzle()
        {
            table = new int[6][];
            table[0] = new int[] { -1, 2, 4, 1, 3, -1 };
            table[1] = new int[] { 3, -1, 0, 5, -1, 2 };
            table[2] = new int[] { 1, 5, -1, -1, 0, 4 };
            table[3] = new int[] { 4, 0, -1, -1, 5, 1 };
            table[4] = new int[] { 2, -1, 5, 0, -1, 3 };
            table[5] = new int[] { -1, 3, 1, 4, 2, -1 };
        }

        public bool Solve(string[] source)
        {
            dices = source;
            memo = new State[n, n];
            used = new bool[n];
            path = new int[n];
            isClear = false;

            for (int i = 0; i < n; i++)
            {
                for (int j = i + 1; j < n; j++)
                {
                    memo[i, j] = new State();
                    memo[j, i] = new State();
                    SearchRoot(i, j);
                }
            }
            DFS(0);
            return isClear;
        }

        private void SearchRoot(int s, int t)
        {
            for (int i = 0; i < 6; i++)
            {
                char temp = char.IsLower(dices[s][i]) ?
                    char.ToUpper(dices[s][i]) :
                    char.ToLower(dices[s][i]);

                for (int j = 0; j < 6; j++)
                {
                    if (dices[t][j] != temp) continue;
                    memo[s, t].root.Add(i);
                    memo[t, s].root.Add(j);
                }
            }
        }

        private void DFS(int depth)
        {
            if (depth == n)
            {
                if (IsClear()) isClear = true;
                return;
            }

            for (int i = 0; i < n; i++)
            {
                if (used[i] || isClear) continue;

                path[depth] = i;
                used[i] = true;
                if (IsValid(depth, i)) DFS(depth + 1);
                used[i] = false;
            }
        }

        private bool IsClear()
        {
            foreach (var s in S)
            {
                foreach (var t in T)
                {
                    if (t.top == GetRev(s.btm)) return true;
                    if (t.btm == GetRev(s.top)) return true;
                }
            }
            return false;
        }

        private string GetRev(string s)
        {
            char[] ret = s.ToCharArray();

            for (int i = 0; i < s.Length; i++)
            {
                ret[i] = char.IsLower(s[i]) ? char.ToUpper(s[i]) : char.ToLower(s[i]);
            }
            return new string(ret);
        }

        private bool IsValid(int depth, int idx)
        {
            if (depth == 0) return true;
            if (memo[path[depth - 1], idx].root.Count == 0) return false;

            switch (depth)
            {
                case 3:
                    if (memo[path[0], path[3]].root.Count == 0) return false;
                    S = Combine(path[0], path[1], path[2], path[3]);
                    if (S.Count == 0) return false;
                    break;
                case 5:
                    if (memo[path[0], path[5]].root.Count == 0) return false;
                    break;
                case 6:
                    if (memo[path[1], path[6]].root.Count == 0) return false;
                    break;
                case 7:
                    if (memo[path[2], path[7]].root.Count == 0) return false;
                    if (memo[path[4], path[7]].root.Count == 0) return false;
                    T = Combine(path[5], path[6], path[7], path[4]);
                    if (T.Count == 0) return false;
                    break;
            }
            return true;
        }

        private List<Comb> Combine(int a, int b, int c, int d)
        {
            List<Comb> ret = new List<Comb>();

            for (int i = 0; i < memo[a, b].root.Count; i++)
            {
                for (int j = 0; j < memo[b, c].root.Count; j++)
                {
                    int inB = memo[b, a].root[i];
                    int outB = memo[b, c].root[j];
                    if (table[inB][outB] == -1) continue;

                    for (int k = 0; k < memo[c, d].root.Count; k++)
                    {
                        int inC = memo[c, b].root[j];
                        int outC = memo[c, d].root[k];
                        if (table[inC][outC] == -1) continue;

                        for (int l = 0; l < memo[d, a].root.Count; l++)
                        {
                            int inD = memo[d, c].root[k];
                            int outD = memo[d, a].root[l];
                            if (table[inD][outD] == -1) continue;

                            int inA = memo[a, d].root[l];
                            int outA = memo[a, b].root[i];
                            if (table[inA][outA] == -1) continue;

                            Comb temp;
                            temp.top =
                                dices[a][table[inA][outA]].ToString() +
                                dices[b][table[inB][outB]].ToString() +
                                dices[c][table[inC][outC]].ToString() +
                                dices[d][table[inD][outD]].ToString();
                            temp.btm =
                                dices[a][table[outA][inA]].ToString() +
                                dices[b][table[outB][inB]].ToString() +
                                dices[c][table[outC][inC]].ToString() +
                                dices[d][table[outD][inD]].ToString();
                            ret.Add(temp);
                        }
                    }
                }
            }
            return ret;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            DicePuzzle dp = new DicePuzzle();

            while (true)
            {
                string input = Console.ReadLine();

                if (input == "0") break;

                string[] arr = new string[8];
                arr[0] = input;

                for (int i = 1; i < 8; i++)
                {
                    arr[i] = Console.ReadLine();
                }
                sb.AppendLine(dp.Solve(arr) ? "YES" : "NO");
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9420