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 Four
    {
        internal string top, btm;
    }

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

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

        List<Four> S;

        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 = (string[])source.Clone();
            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()
        {
            int[] temp = new int[] { path[5], path[6], path[7], path[4] };
            var T = MakeFour(temp);

            foreach (var s in S)
            {
                string tempTop = GetRev(s.top);
                string tempBtm = GetRev(s.btm);

                foreach (var t in T)
                {
                    if (t.top == tempBtm) return true;
                    if (t.btm == tempTop) return true;
                }
            }
            return false;
        }

        private string GetRev(string s)
        {
            string ret = "";

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

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

            if (depth == 3)
            {
                int[] arr = new int[] { path[0], path[1], path[2], path[3] };
                S = MakeFour(arr);
                if (S.Count == 0) return false;
            }
            return true;
        }

        private List<Four> MakeFour(int[] arr)
        {
            List<Four> ret = new List<Four>();

            int a = arr[0], b = arr[1], c = arr[2], d = arr[3];

            for (int i = 0; i < memo[a, b].root.Count; i++)
            {
                int outA = memo[a, b].root[i];
                int inB = memo[b, a].root[i];

                for (int j = 0; j < memo[b, c].root.Count; j++)
                {
                    int outB = memo[b, c].root[j];
                    int inC = memo[c, b].root[j];

                    if (table[inB][outB] == -1) continue;

                    for (int k = 0; k < memo[c, d].root.Count; k++)
                    {
                        int outC = memo[c, d].root[k];
                        int inD = memo[d, c].root[k];

                        if (table[inC][outC] == -1) continue;

                        for (int l = 0; l < memo[d, a].root.Count; l++)
                        {
                            int outD = memo[d, a].root[l];
                            int inA = memo[a, d].root[l];

                            if (table[inD][outD] == -1) continue;
                            if (table[inA][outA] == -1) continue;

                            Four 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: 9632