During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation of one face of the cube in any direction.To check her answers she wants to use a program which will for some state of cube tell if it's possible to solve it using one rotation, described above.Cube is called solved if for each face of cube all squares on it has the same color.https://en.wikipedia.org/wiki/Rubik's_Cube

In first line given a sequence of 24 integers ai (1 ≤ ai ≤ 6), where ai denotes color of i-th square. There are exactly 4 occurrences of all colors in this sequence.

Print «YES» (without quotes) if it's possible to solve cube using one rotation and «NO» (without quotes) otherwise.

NoteIn first test case cube looks like this:  In second test case cube looks like this:   It's possible to solve cube by rotating face with squares with numbers 13, 14, 15, 16.

using System;
using System.IO;
using System.Text;

namespace Solution_for_Cube
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args) ? "YES" : "NO");
            writer.Flush();
        }

        private static bool Solve(string[] args)
        {
            int n = 24;

            var a = new int[n + 1];
            for (int i = 1; i <= n; i++)
            {
                a[i] = Next();
            }

            if (check(a))
                return true;

            var b = new int[n + 1];

            b[13] = a[5];
            b[14] = a[6];
            b[15] = a[7];
            b[16] = a[8];

            b[5] = a[17];
            b[6] = a[18];
            b[7] = a[19];
            b[8] = a[20];

            b[17] = a[21];
            b[18] = a[22];
            b[19] = a[23];
            b[20] = a[24];

            b[21] = a[13];
            b[22] = a[14];
            b[23] = a[15];
            b[24] = a[16];

            b[1] = a[3];
            b[2] = a[1];
            b[3] = a[4];
            b[4] = a[2];

            b[9] = a[10];
            b[10] = a[12];
            b[11] = a[9];
            b[12] = a[11];

            if (check(b))
                return true;

            var c = new int[n + 1];

            c[1] = a[18];
            c[2] = a[20];
            c[3] = a[17];
            c[4] = a[19];

            c[5] = a[6];
            c[6] = a[8];
            c[7] = a[5];
            c[8] = a[7];

            c[9] = a[14];
            c[10] = a[16];
            c[11] = a[13];
            c[12] = a[15];

            c[13] = a[2];
            c[14] = a[4];
            c[15] = a[1];
            c[16] = a[3];

            c[17] = a[10];
            c[18] = a[12];
            c[19] = a[9];
            c[20] = a[11];

            c[21] = a[23];
            c[22] = a[21];
            c[23] = a[24];
            c[24] = a[22];

            if (check(c))
                return true;

            return false;
        }

        private static bool check(int[] a)
        {
            if (a[13] == a[14] && a[15] == a[16] && a[13] == a[15]
                && a[17] == a[18] && a[17] == a[19] && a[17] == a[20])
            {
                for (int i = 3; i < a.Length; i += 3)
                {
                    if (a[i] != a[i - 2])
                        return false;
                    i++;
                    if (a[i] != a[i - 2])
                        return false;
                }

                var b = new[] {a[1], a[5], a[9], a[22]};
                var c = new[] {a[2], a[6], a[10], a[21]};

                for (int i = 1; i < 4; i += 2)
                {
                    bool ok = true;

                    for (int j = 0; j < 4; j++)
                    {
                        if (b[(j + i)%4] != c[j])
                        {
                            ok = false;
                            break;
                        }
                    }

                    if (ok)
                        return true;
                }
            }
            return false;
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;
namespace _887C
{
    internal class Program
    {
        private static int[][] rotates =
        {
            new[] {13, 14, 5, 6, 17, 18, 21, 22},
            new[] {15, 16, 7, 8, 19, 20, 23, 24},
            new[] {1, 3, 5, 7, 9, 11, 24, 22},
            new[] {2, 4, 6, 8, 10, 12, 23, 21},
            new[] {1, 2, 18, 20, 12, 11, 15, 13},
            new[] {3, 4, 17, 19, 10, 9, 16, 14}
        };

        static bool Check(int[] a)
        {
            bool res = true;
            for (int i = 0; i < 6; i++)
            {
                int color = a[i * 4];
                for (int j = 1; j < 4; j++)
                    if (a[i * 4 + j] != color)
                        res = false;
            }
            return res;
        }
        public static void Main(string[] args)
        {
            int[] a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            bool result = false;
            for (int i = 0; i < 6; i++)
            {
                int[] b = new int[24];
                Array.Copy(a, b, 24);
                for (int j = 0; j < 8; j++)
                {
                    int next = j + 2;
                    if (next >= 8) next -= 8;
                    b[rotates[i][j] - 1] = a[rotates[i][next] - 1];
                }
                result |= Check(b);
                Array.Copy(a, b, 24);
                for (int j = 0; j < 8; j++)
                {
                    int next = j - 2;
                    if (next < 0) next += 8;
                    b[rotates[i][j] - 1] = a[rotates[i][next] - 1];
                }
                result |= Check(b);
            }
            Console.WriteLine(result ? "YES" : "NO");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Codeforces {
    static int[] F;
    static void Main(String[] args) {
#if LOCAL
        Console.SetIn(new System.IO.StreamReader("input"));
#endif

        F = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

        int[] rep1 = { 12, 13, 4, 5, 16, 17, 20, 21 };
        int[] rep2 = { 14, 15, 6, 7, 18, 19, 22, 23 };
        int[] rep3 = { 0, 2, 4, 6, 8, 10, 23, 21 };
        int[] rep4 = { 1, 3, 5, 7, 9, 11, 22, 20 };
        int[] rep5 = { 2, 3, 16, 18, 9, 8, 15, 13 };
        int[] rep6 = { 0, 1, 17, 19, 11, 10, 14, 12 };

        bool valid = rotate(rep1) || rotate(rep2) || rotate(rep3) || rotate(rep4) || rotate(rep5) || rotate(rep6);
        Console.WriteLine(valid ? "YES" : "NO");
    }

    private static bool rotate(int[] rep) {
        int[] f2 = new int[24];

        for (int i = 0; i < 24; i++) f2[i] = F[i];
        for (int i = 0; i < 8; i++) {
            f2[rep[i]] = F[rep[(8 + i - 2) % 8]];
        }

        int[] f3 = new int[24];

        for (int i = 0; i < 24; i++) f3[i] = F[i];
        for (int i = 0; i < 8; i++) {
            f3[rep[i]] = F[rep[(i + 2) % 8]];
        }

        return check(f2) || check(f3);
    }

    private static bool check(int[] F) {
        for (int i = 0; i < F.Length; i += 4) {
            if (!(F[i] == F[i + 1] && F[i] == F[i + 2] && F[i] == F[i + 3])) return false;
        }
        return true;
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

namespace CF
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            using (var sr = new InputReader(Console.In))
//			using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
                //using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;
        private readonly TextWriter sw;
        private bool isDispose;

        public Task(InputReader sr, TextWriter sw)
        {
            this.sr = sr;
            this.sw = sw;
        }

        public void Solve()
        {
            const int max = 25;
            var input = sr.ReadArrayOfInt32();
            var colors = new int[max];
            for (var i = 1; i < max; i++) {
                colors[i] = input[i - 1];
            }
            if (Check(Move1(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move2(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move3(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move4(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move5(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move6(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move7(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move8(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move9(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move10(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move11(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move12(colors))) {
                sw.WriteLine("YES");
                return;
            }

            sw.WriteLine("NO");
        }

        private int[] Move1(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[2] = colors[6];
            result[4] = colors[8];

            result[6] = colors[10];
            result[8] = colors[12];

            result[10] = colors[23];
            result[12] = colors[21];

            result[21] = colors[4];
            result[23] = colors[2];

            result[18] = colors[17];
            result[20] = colors[18];
            result[19] = colors[20];
            result[17] = colors[19];

            return result;
        }

        private int[] Move2(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[2] = colors[23];
            result[4] = colors[21];

            result[6] = colors[2];
            result[8] = colors[4];

            result[10] = colors[6];
            result[12] = colors[8];

            result[21] = colors[12];
            result[23] = colors[10];

            result[18] = colors[20];
            result[20] = colors[19];
            result[19] = colors[17];
            result[17] = colors[18];

            return result;
        }

        private int[] Move3(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[1] = colors[5];
            result[3] = colors[7];

            result[6] = colors[9];
            result[7] = colors[11];

            result[9] = colors[24];
            result[11] = colors[22];

            result[22] = colors[3];
            result[24] = colors[1];

            result[14] = colors[16];
            result[16] = colors[15];
            result[15] = colors[13];
            result[13] = colors[14];

            return result;
        }

        private int[] Move4(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[1] = colors[24];
            result[3] = colors[22];

            result[5] = colors[1];
            result[7] = colors[3];

            result[9] = colors[5];
            result[11] = colors[7];

            result[22] = colors[11];
            result[24] = colors[9];

            result[14] = colors[13];
            result[16] = colors[14];
            result[15] = colors[16];
            result[13] = colors[15];

            return result;
        }

        private int[] Move5(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[13] = colors[5];
            result[14] = colors[6];

            result[5] = colors[17];
            result[6] = colors[18];

            result[17] = colors[21];
            result[18] = colors[22];

            result[21] = colors[13];
            result[22] = colors[14];

            result[4] = colors[3];
            result[2] = colors[4];
            result[1] = colors[2];
            result[3] = colors[1];

            return result;
        }

        private int[] Move6(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[22] = colors[14];
            result[21] = colors[13];

            result[14] = colors[5];
            result[13] = colors[6];

            result[5] = colors[17];
            result[6] = colors[18];

            result[17] = colors[21];
            result[18] = colors[22];

            result[3] = colors[4];
            result[4] = colors[2];
            result[2] = colors[1];
            result[1] = colors[3];

            return result;
        }

        private int[] Move7(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[15] = colors[7];
            result[16] = colors[8];

            result[7] = colors[19];
            result[8] = colors[20];

            result[19] = colors[23];
            result[20] = colors[24];

            result[23] = colors[15];
            result[24] = colors[16];

            result[10] = colors[9];
            result[12] = colors[10];
            result[11] = colors[12];
            result[9] = colors[11];

            return result;
        }

        private int[] Move8(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[24] = colors[16];
            result[23] = colors[15];

            result[16] = colors[7];
            result[15] = colors[8];

            result[7] = colors[19];
            result[8] = colors[20];

            result[19] = colors[23];
            result[20] = colors[24];

            result[9] = colors[10];
            result[10] = colors[12];
            result[12] = colors[11];
            result[11] = colors[9];

            return result;
        }

        private int[] Move9(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[16] = colors[3];
            result[14] = colors[4];

            result[10] = colors[16];
            result[9] = colors[14];

            result[17] = colors[10];
            result[19] = colors[9];

            result[3] = colors[17];
            result[4] = colors[19];

            result[5] = colors[6];
            result[6] = colors[8];
            result[8] = colors[7];
            result[7] = colors[5];

            return result;
        }

        private int[] Move10(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[3] = colors[16];
            result[4] = colors[14];

            result[16] = colors[10];
            result[14] = colors[9];

            result[10] = colors[17];
            result[9] = colors[19];

            result[17] = colors[3];
            result[4] = colors[19];

            result[6] = colors[5];
            result[8] = colors[6];
            result[7] = colors[8];
            result[5] = colors[7];

            return result;
        }

        private int[] Move11(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[15] = colors[1];
            result[13] = colors[2];

            result[12] = colors[15];
            result[11] = colors[13];

            result[18] = colors[12];
            result[20] = colors[11];

            result[1] = colors[18];
            result[2] = colors[20];

            result[21] = colors[23];
            result[22] = colors[21];
            result[24] = colors[22];
            result[23] = colors[24];

            return result;
        }

        private int[] Move12(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[1] = colors[15];
            result[2] = colors[13];

            result[15] = colors[12];
            result[13] = colors[11];

            result[12] = colors[18];
            result[11] = colors[20];

            result[18] = colors[1];
            result[20] = colors[2];

            result[23] = colors[21];
            result[21] = colors[22];
            result[22] = colors[24];
            result[24] = colors[23];

            return result;
        }

        private bool Check(int[] colors)
        {
            for (var i = 0; i < 6; i++) {
                var startIndx = i * 4 + 1;
                if (!(colors[startIndx] == colors[startIndx + 1] && colors[startIndx] == colors[startIndx + 2]
                    && colors[startIndx] == colors[startIndx + 2] && colors[startIndx] == colors[startIndx + 3])) {
                    return false;
                }
            }

            return true;
        }

        ~Task()
        {
            Dispose(false);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}

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

   public class C
    {
          static  bool checkOk(int s , int [] inputs)
        {
            int c = inputs[s*4];
            for(int i = 0;i<4; i++)
            {
                if (c != inputs[s * 4 + i])
                    return false;
            }

            return true;
        }

        static bool  checkRotation(int [,] arr, int [] inp ,int aindex )
        {

            int[] farr = new int[8];
            int[] sarr = new int[8];
            int fp=0, sp = 0;
            for(int  i = 1; i < 9; i++)
            {
                farr[fp++] =  inp[arr[aindex,i]];
                sarr[sp++] = inp[arr[aindex+1, i]];
            }

            bool  checkR = false;
            for(int  i = 0; i < 8; i++)
            {
                if (farr[i] != sarr[(i + 2) % 8])
                    checkR=true;

            }

            if (!checkR)
                return true;

            for (int i = 0; i < 8; i++)
            {
                if (farr[i] != sarr[(i - 2+8) % 8])
                    return false;

            }

            return true;
        }

        static void Main(string[] args)
        {
            int[,] arr = { { 0, 12, 13,4,5,16,17,20,21 },{ 2,14,15,6,7,18,19,22,23}, { 1,1,0,12,14,10,11,19,17 }, { 5,3,2,13,15,8,9,18,16}, { 3, 0,2,4,6,8,10,23,21} ,{ 4,1,3,5,7,9,11,22,20} };

            string inp = Console.ReadLine();
            int[] inputs = new int[24];
            string[] splits = inp.Split(' ');

            for(int i  =0; i < 24; i++)
            {
                inputs[i] = int.Parse(splits[i]);
            }
            bool isPoss = false;
            for(int  i =0; i<6; i+=2)
            {
                if(checkOk(arr[i,0], inputs) && checkOk(arr[i+1, 0], inputs))
                {

                 isPoss  =  checkRotation(arr, inputs, i);
                    break;
                }

            }
            if(isPoss)
                        Console.Write("YES");
                    else
                        Console.Write("NO");

        }
    }

using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var staticFaces = isHasExactlyTwoFacesSameColor(getAllFaces(input));
            if (staticFaces == -1)
            {
                Console.WriteLine("NO");
            }
            else
            {
                var L = rotateL(input, staticFaces);
                var R = rotateR(input, staticFaces);
                Console.WriteLine((isAllFacesSameColor(L) || isAllFacesSameColor(R)) ? "YES" : "NO");
            }
        }

        static List<int[]> getAllFaces(string[] input)
        {
            List<int[]> faces = new List<int[]>();
            for (int i = 0; i < 6; i++)
            {
                faces.Add(new int[]
                {
                    int.Parse(input[i*4]),
                    int.Parse(input[i*4+1]),
                    int.Parse(input[i*4+2]),
                    int.Parse(input[i*4+3])
                });
            }
            return faces;
        }

        static int isHasExactlyTwoFacesSameColor(List<int[]> faces)
        {
            int result = -1;
            if (isFaceSameColor(faces[0]) && isFaceSameColor(faces[2])) result = 13;

            if (isFaceSameColor(faces[3]) && isFaceSameColor(faces[4]))
                if (result == -1) result = 45;
                else return -1;

            if (isFaceSameColor(faces[1]) && isFaceSameColor(faces[5]))
                if (result == -1) result = 26;
                else return -1;

            return result;
        }

        static bool isFaceSameColor(int[] face)
        {
            var j = face[0];
            foreach (int i in face)
            {
                if (i != j) return false;
            }
            return true;
        }

        static bool isAllFacesSameColor(List<int[]> faces)
        {
            foreach (var f in faces)
            {
                if (!isFaceSameColor(f)) return false;
            }
            return true;
        }

        static List<int[]> rotateL(string[] input, int staticFaces)
        {
            string[] ip = new string[input.Length];
            Array.Copy(input, ip, input.Length);
            if (staticFaces == 45)
            {
                string a = ip[1];
                string b = ip[3];
                ip[1] = ip[5];
                ip[3] = ip[7];
                ip[5] = ip[9];
                ip[7] = ip[11];
                ip[9] = ip[22];
                ip[11] = ip[20];
                ip[22] = a;
                ip[20] = b;
            }
            else if (staticFaces == 13)
            {
                string a = ip[21];
                string b = ip[20];
                ip[21] = ip[17];
                ip[20] = ip[16];
                ip[17] = ip[5];
                ip[16] = ip[4];
                ip[5] = ip[13];
                ip[4] = ip[12];
                ip[13] = a;
                ip[12] = b;
            }
            else if (staticFaces == 26)
            {
                string a = ip[0];
                string b = ip[1];
                ip[0] = ip[17];
                ip[1] = ip[19];
                ip[17] = ip[11];
                ip[19] = ip[10];
                ip[11] = ip[14];
                ip[10] = ip[12];
                ip[14] = a;
                ip[12] = b;
            }
            return getAllFaces(ip);
        }

        static List<int[]> rotateR(string[] input, int staticFaces)
        {
            string[] ip = new string[input.Length];
            Array.Copy(input, ip, input.Length);
            if (staticFaces == 45)
            {
                string a = ip[11];
                string b = ip[9];
                ip[11] = ip[7];
                ip[9] = ip[5];
                ip[7] = ip[3];
                ip[5] = ip[1];
                ip[3] = ip[20];
                ip[1] = ip[22];
                ip[20] = a;
                ip[22] = b;
            }
            else if (staticFaces == 13)
            {
                string a = ip[12];
                string b = ip[13];
                ip[12] = ip[4];
                ip[13] = ip[5];
                ip[4] = ip[16];
                ip[5] = ip[17];
                ip[16] = ip[20];
                ip[17] = ip[21];
                ip[20] = a;
                ip[21] = b;
            }
            else if (staticFaces == 26)
            {
                string a = ip[10];
                string b = ip[11];
                ip[10] = ip[19];
                ip[11] = ip[17];
                ip[19] = ip[1];
                ip[17] = ip[0];
                ip[1] = ip[12];
                ip[0] = ip[14];
                ip[12] = a;
                ip[14] = b;
            }
            return getAllFaces(ip);
        }
    }
}

using System;

namespace BT887C
{
    class Program
    {
        static void Main(string[] args)
        {
            const int faceSize = 4;
            const int faceNum = 6;

            int[] arr = new int[faceNum * faceSize];

            string input = Console.ReadLine();

            string[] splitRes = input.Split(' ');
            for (int i = 0; i < faceSize * faceNum; i++)
            {
                var item = splitRes[i];
                arr[i] = int.Parse(item);
            }
            int[,] cir;
            if (IsCompleteFace(arr, 0) && IsCompleteFace(arr, 2))
            {
                cir = toListArr(arr, faceSize * 3, faceSize * 1, faceSize * 4, faceSize * 5);
            }
            else if (IsCompleteFace(arr, 1) && IsCompleteFace(arr, 5))
            {
                RotateLeft(arr, faceSize * 0);
                RotateLeft(arr, faceSize * 0);

                RotateRight(arr, faceSize * 3);

                RotateLeft(arr, faceSize * 4);

                cir = toListArr(arr, faceSize * 0, faceSize * 3, faceSize * 2, faceSize * 4);

            }
            else if (IsCompleteFace(arr, 3) && IsCompleteFace(arr, 4))
            {
                RotateRight(arr, faceSize * 0);
                RotateRight(arr, faceSize * 1);
                RotateRight(arr, faceSize * 2);
                RotateByRightDiagonal(arr, faceSize * 5);
                cir = toListArr(arr, faceSize * 0, faceSize * 1, faceSize * 2, faceSize * 5);
            }
            else
            {
                Console.WriteLine(returnString(false));
                return;
            }

            int index = 0;
            bool result = false;
            for (int i = 1; i < 8; i++)
            {
                if (cir[0, 0] == cir[1, i] && ((8 - i <= 2 || i <= 2)))
                {
                    index = i;
                    bool flag = true;
                    for (int j = 0; j < 8; j++)
                    {
                        if (cir[0, j] != cir[1, ((index + j) % 8)])
                            flag = false;
                    }
                    if (flag == true)
                    {
                        result = true;
                        break;
                    }
                }
            }

            Console.WriteLine(returnString(result));
            return;

        }

        static int[,] toListArr(int[] arr, int index1, int index2, int index3, int index4)
        {
            int[,] returnArr = new int[2, 8];
            returnArr[0, 0] = arr[index1];
            returnArr[0, 1] = arr[index1 + 1];
            returnArr[0, 2] = arr[index2];
            returnArr[0, 3] = arr[index2 + 1];
            returnArr[0, 4] = arr[index3];
            returnArr[0, 5] = arr[index3 + 1];
            returnArr[0, 6] = arr[index4];
            returnArr[0, 7] = arr[index4 + 1];
            returnArr[1, 0] = arr[index1 + 2];
            returnArr[1, 1] = arr[index1 + 3];
            returnArr[1, 2] = arr[index2 + 2];
            returnArr[1, 3] = arr[index2 + 3];
            returnArr[1, 4] = arr[index3 + 2];
            returnArr[1, 5] = arr[index3 + 3];
            returnArr[1, 6] = arr[index4 + 2];
            returnArr[1, 7] = arr[index4 + 3];

            return returnArr;
        }

        static void RotateLeft(int[] arr, int startIndex)
        {
            int temp = arr[startIndex];
            arr[startIndex] = arr[startIndex + 2];
            arr[startIndex + 2] = arr[startIndex + 3];
            arr[startIndex + 3] = arr[startIndex + 1];
            arr[startIndex + 1] = temp;

        }

        static void RotateRight(int[] arr, int startIndex)
        {
            int temp = arr[startIndex];
            arr[startIndex] = arr[startIndex + 1];
            arr[startIndex + 1] = arr[startIndex + 3];
            arr[startIndex + 3] = arr[startIndex + 2];
            arr[startIndex + 2] = temp;
        }

        static void RotateByRightDiagonal(int[] arr, int startIndex)
        {
            int temp = arr[startIndex + 1];
            arr[startIndex + 1] = arr[startIndex + 2];
            arr[startIndex + 2] = temp;

        }

        //static void RotateDown(int[] arr, int startIndex)
        //{
        //    int temp = arr[startIndex];
        //    arr[startIndex] = arr[startIndex + 2];
        //    arr[startIndex + 1] = arr[startIndex];
        //    arr[startIndex + 2] = arr[startIndex + 3];
        //    arr[startIndex + 3] = arr[startIndex + 1];
        //}

        static bool IsCompleteFace(int[] face, int faceIndex)
        {
            const int faceSize = 4;

            int pattern = face[faceIndex * faceSize];
            for (int i = 0; i < faceSize; i++)
            {
                if (face[faceIndex * faceSize + i] != pattern)
                    return false;
            }
            return true;
        }

        static string returnString(bool res)
        {
            if (res)
                return "YES";
            else
                return "NO";
        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
public class CodeForces
{
#if TEST
// To set this go to Project -> Properties -> Build -> General -> Conditional compilation symbols: -> enter 'TEST' into text box.
const bool testing = true;
#else
    const bool testing = false;
#endif

    static void program(TextReader input)
    {
        var s = input.ReadLine().Split(' ').Select(int.Parse).ToList();

        var trans = new List<List<int>>() {
            new List<int>(){1,3,5,7,9,11,24,22},
            new List<int>(){2,4,6,8,10,12,23,21},
            new List<int>(){13,14,5,6,17,18,21,22},
            new List<int>(){15,16,7,8,19,20,23,24},
            new List<int>(){15,16,7,8,19,20,23,24},
            new List<int>(){14,3,4,17,19,10,9,16},
            new List<int>(){13,1,2,18,20,12,11,15}
        };

        for(var i = 0; i < trans.Count; i++)
        {
            var newS = s.ToList();
            for(var j = 0; j < trans[i].Count; j++)
            {
                newS[trans[i][j] - 1] = s[trans[i][(j + 2) % 8] - 1];
            }

            var pos = true;
            for(var k = 0; k < 5; k++)
            {
                var color = newS[k * 4];
                for(var j = k * 4 + 1; j < (k + 1) * 4; j++)
                {
                    if(newS[j] != color)
                    {
                        pos = false;
                    }
                }
            }

            if (pos)
            {
                Console.WriteLine("YES");
                return;
            }

            newS = s.ToList();
            for (var j = 0; j < trans[i].Count; j++)
            {
                newS[trans[i][j] - 1] = s[trans[i][(j +6) % 8] - 1];
            }

            pos = true;
            for (var k = 0; k < 5; k++)
            {
                var color = newS[k * 4];
                for (var j = k * 4 + 1; j < (k + 1) * 4; j++)
                {
                    if (newS[j] != color)
                    {
                        pos = false;
                    }
                }
            }
            if (pos)
            {
                Console.WriteLine("YES");
                return;
            }
        }

        Console.WriteLine("NO");

    }

    public static void Main(string[] args)
    {
        if (!testing)
        { // set testing to false when submiting to codeforces
            program(Console.In); // write your program in 'program' function (its your new main !)
            return;
        }

        Console.WriteLine("Test Case(1) => expected :");
        Console.WriteLine("NO");
        Console.WriteLine("Test Case(1) => found    :");
        program(new StringReader("2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4\n"));
        Console.WriteLine();

        Console.WriteLine("Test Case(2) => expected :");
        Console.WriteLine("YES");
        Console.WriteLine("Test Case(2) => found    :");
        program(new StringReader("5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3\n"));
        Console.WriteLine();

    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    int[] a;
    int[] Parse(string s)
    {
        return s.Split(',').Select(ss => a[int.Parse(ss) - 1]).ToArray();
    }

    bool Fun(string left, string right, string c1, string c2)
    {
        var l = Parse(left);
        var r = Parse(right);
        var v1 = Parse(c1);
        var v2 = Parse(c2);
        if (l.Distinct().Count() > 1 || r.Distinct().Count() > 1)
            return false;

        for (int i = 0; i < 8; i += 2)
            if (v1[i] != v1[i + 1])
                return false;

        bool f = true;
        for (int i = 0; i < 8; i++)
            if (v1[i] != v2[(i + 2) % 8])
                f = false;
        if (f)
            return true;
        f = true;
        for (int i = 0; i < 8; i++)
            if (v1[i] != v2[(i + 6) % 8])
                f = false;
        return f;
    }

    public void Solve()
    {
        a = ReadIntArray();

        Write(Fun("13,14,15,16", "17,18,19,20", "1,3,5,7,9,11,24,22", "2,4,6,8,10,12,23,21") ||
            Fun("1,2,3,4", "9,10,11,12", "13,14,5,6,17,18,21,22", "15,16,7,8,19,20,23,24") ||
            Fun("5,6,7,8", "21,22,23,24", "3,4,17,19,10,9,16,14", "1,2,18,20,12,11,15,13") ? "YES" : "NO");
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            new Solver().Solve();
            //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}

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

namespace codeforce
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            for (int i = 1; i <= 8; i++)
            {
                string[] ss = s.Split(' ');
                if (isCubeOk(Rotate(ss, i)))
                {
                    Console.Write("YES");
                    //Console.ReadLine();
                    return;
                }
            }

            Console.Write("NO");

            //Console.ReadLine();
        }

        private static string[] Rotate(string[] ss,int r)
        {
            if(r==1)
                TW(ref ss, "2,6 4,8 6,10 8,12 10,23 12,21 21,4 23,2");
            else if (r == 2)
                TW(ref ss, "2,23 4,21 6,2 8,4 10,6 12,8 23,10 21,12");
            else if (r == 3)
                TW(ref ss, "1,5 3,7 5,9 7,11 9,24 11,22 22,3 24,1");
            else if (r == 4)
                TW(ref ss, "5,1 7,3 9,5 11,7 1,24 3,22 24,9 22,11");

            else if (r == 5)
                TW(ref ss, "13,5 14,6 5,17 6,18 17,21 18,22 21,13 22,14");
            else if (r == 6)
                TW(ref ss, "5,13 6,14 17,5 18,6 21,17 22,18 13,21 14,22");

            else if (r == 7)
                TW(ref ss, "7,15 8,16 19,7 20,8 23,19 24,20 15,23 16,24");
            else if (r == 8)
                TW(ref ss, "15,7 16,8 7,19 8,20 19,23 20,24 23,15 24,16");

            return ss;
        }

        private static bool isCubeOk(string[] ss)
        {
            int c = 0;
            for (int i = 0; i < 24; i=i+4)
                if (ss[i] == ss[i + 1] && ss[i] == ss[i + 2] && ss[i] == ss[i + 3])
                    c++;
            if (c == 6)
                return true;
            return false;
        }

        private static void TW(ref string[] ss,string tw)
        {
            string[] pp = new string[ss.Length];
            ss.CopyTo(pp, 0);
            string[] ff = tw.Split(' ');
            for (int i = 0; i < ff.Length; i++)
            {
                int k1 = Int32.Parse(ff[i].Split(',')[0])-1;
                int k2 = Int32.Parse(ff[i].Split(',')[1])-1;
                ss[k2] = pp[k1];
            }
        }
    }
}

using System;
using System.IO;
using System.Text;

namespace Solution_for_Cube
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args) ? "YES" : "NO");
            writer.Flush();
        }

        private static bool Solve(string[] args)
        {
            int n = 24;

            var a = new int[n + 1];
            for (int i = 1; i <= n; i++)
            {
                a[i] = Next();
            }

            if (check(a))
                return true;

            var b = new int[n + 1];

            b[13] = a[5];
            b[14] = a[6];
            b[15] = a[7];
            b[16] = a[8];

            b[5] = a[17];
            b[6] = a[18];
            b[7] = a[19];
            b[8] = a[20];

            b[17] = a[21];
            b[18] = a[22];
            b[19] = a[23];
            b[20] = a[24];

            b[21] = a[13];
            b[22] = a[14];
            b[23] = a[15];
            b[24] = a[16];

            b[1] = a[3];
            b[2] = a[1];
            b[3] = a[4];
            b[4] = a[2];

            b[9] = a[10];
            b[10] = a[12];
            b[11] = a[9];
            b[12] = a[11];

            if (check(b))
                return true;

            var c = new int[n + 1];

            c[1] = a[18];
            c[2] = a[20];
            c[3] = a[17];
            c[4] = a[19];

            c[5] = a[6];
            c[6] = a[8];
            c[7] = a[5];
            c[8] = a[7];

            c[9] = a[14];
            c[10] = a[16];
            c[11] = a[13];
            c[12] = a[15];

            c[13] = a[2];
            c[14] = a[4];
            c[15] = a[1];
            c[16] = a[3];

            c[17] = a[10];
            c[18] = a[12];
            c[19] = a[9];
            c[20] = a[11];

            c[21] = a[23];
            c[22] = a[21];
            c[23] = a[24];
            c[24] = a[22];

            if (check(c))
                return true;

            return false;
        }

        private static bool check(int[] a)
        {
            if (a[13] == a[14] && a[15] == a[16] && a[13] == a[15]
                && a[17] == a[18] && a[17] == a[19] && a[17] == a[20])
            {
                for (int i = 3; i < a.Length; i += 3)
                {
                    if (a[i] != a[i - 2])
                        return false;
                    i++;
                    if (a[i] != a[i - 2])
                        return false;
                }

                var b = new[] {a[1], a[5], a[9], a[22]};
                var c = new[] {a[2], a[6], a[10], a[21]};

                for (int i = 1; i < 4; i += 3)
                {
                    bool ok = true;

                    for (int j = 0; j < 4; j++)
                    {
                        if (b[(j + i)%4] != c[j])
                        {
                            ok = false;
                            break;
                        }
                    }

                    if (ok)
                        return true;
                }
            }
            return false;
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;
using System.IO;
using System.Text;

namespace Solution_for_Cube
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args) ? "YES" : "NO");
            writer.Flush();
        }

        private static bool Solve(string[] args)
        {
            int n = 24;

            var a = new int[n + 1];
            for (int i = 1; i <= n; i++)
            {
                a[i] = Next();
            }

            if (check(a))
                return true;

            var b = new int[n + 1];

            b[13] = a[5];
            b[14] = a[6];
            b[15] = a[7];
            b[16] = a[8];

            b[5] = a[17];
            b[6] = a[18];
            b[7] = a[19];
            b[8] = a[20];

            b[17] = a[21];
            b[18] = a[22];
            b[19] = a[23];
            b[20] = a[24];

            b[21] = a[13];
            b[22] = a[14];
            b[23] = a[15];
            b[24] = a[16];

            b[1] = a[3];
            b[2] = a[1];
            b[3] = a[4];
            b[4] = a[2];

            b[9] = a[10];
            b[10] = a[12];
            b[11] = a[9];
            b[12] = a[11];

            if (check(b))
                return true;

            var c = new int[n + 1];

            c[1] = a[5];
            c[2] = a[6];
            c[3] = a[7];
            c[4] = a[8];

            c[5] = a[9];
            c[6] = a[10];
            c[7] = a[11];
            c[8] = a[12];

            c[9] = a[24];
            c[10] = a[22];
            c[11] = a[23];
            c[12] = a[21];

            c[13] = a[14];
            c[14] = a[16];
            c[15] = a[13];
            c[16] = a[15];

            c[17] = a[19];
            c[18] = a[17];
            c[19] = a[20];
            c[20] = a[18];

            c[21] = a[4];
            c[22] = a[3];
            c[23] = a[2];
            c[24] = a[1];

            if (check(c))
                return true;

            return false;
        }

        private static bool check(int[] a)
        {
            if (a[13] == a[14] && a[15] == a[16] && a[13] == a[15]
                && a[17] == a[18] && a[17] == a[19] && a[17] == a[20])
            {
                for (int i = 3; i < a.Length; i += 3)
                {
                    if (a[i] != a[i - 2])
                        return false;
                    i++;
                    if (a[i] != a[i - 2])
                        return false;
                }

                var b = new[] {a[1], a[5], a[9], a[22]};
                var c = new[] {a[2], a[6], a[10], a[21]};

                for (int i = 0; i < 4; i++)
                {
                    bool ok = true;

                    for (int j = 0; j < 4; j++)
                    {
                        if (b[(j + i)%4] != c[j])
                        {
                            ok = false;
                            break;
                        }
                    }

                    if (ok)
                        return true;
                }
            }
            return false;
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;
using System.IO;
using System.Text;

namespace Solution_for_Cube
{
    internal class Program
    {
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024*10), Encoding.ASCII, false, 1024*10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024*10), Encoding.ASCII, 1024*10);

        private static void Main(string[] args)
        {
            writer.WriteLine(Solve(args) ? "YES" : "NO");
            writer.Flush();
        }

        private static bool Solve(string[] args)
        {
            int n = 24;

            var a = new int[n + 1];
            for (int i = 1; i <= n; i++)
            {
                a[i] = Next();
            }

            if (check(a))
                return true;

            var b = new int[n + 1];

            b[13] = a[5];
            b[14] = a[6];
            b[15] = a[7];
            b[16] = a[8];

            b[5] = a[17];
            b[6] = a[18];
            b[7] = a[19];
            b[8] = a[20];

            b[17] = a[21];
            b[18] = a[22];
            b[19] = a[23];
            b[20] = a[24];

            b[21] = a[13];
            b[22] = a[14];
            b[23] = a[15];
            b[24] = a[16];

            b[1] = a[3];
            b[2] = a[1];
            b[3] = a[4];
            b[4] = a[2];

            b[9] = a[10];
            b[10] = a[12];
            b[11] = a[9];
            b[12] = a[11];

            if (check(b))
                return true;

            var c = new int[n + 1];

            c[1] = a[18];
            c[2] = a[20];
            c[3] = a[17];
            c[4] = a[19];

            c[5] = a[6];
            c[6] = a[8];
            c[7] = a[5];
            c[8] = a[7];

            c[9] = a[14];
            c[10] = a[16];
            c[11] = a[13];
            c[12] = a[15];

            c[13] = a[2];
            c[14] = a[4];
            c[15] = a[1];
            c[16] = a[3];

            c[17] = a[10];
            c[18] = a[12];
            c[19] = a[9];
            c[20] = a[11];

            c[21] = a[23];
            c[22] = a[21];
            c[23] = a[24];
            c[24] = a[22];

            if (check(c))
                return true;

            return false;
        }

        private static bool check(int[] a)
        {
            if (a[13] == a[14] && a[15] == a[16] && a[13] == a[15]
                && a[17] == a[18] && a[17] == a[19] && a[17] == a[20])
            {
                for (int i = 3; i < a.Length; i += 3)
                {
                    if (a[i] != a[i - 2])
                        return false;
                    i++;
                    if (a[i] != a[i - 2])
                        return false;
                }

                var b = new[] {a[1], a[5], a[9], a[22]};
                var c = new[] {a[2], a[6], a[10], a[21]};

                for (int i = 0; i < 4; i++)
                {
                    bool ok = true;

                    for (int j = 0; j < 4; j++)
                    {
                        if (b[(j + i)%4] != c[j])
                        {
                            ok = false;
                            break;
                        }
                    }

                    if (ok)
                        return true;
                }
            }
            return false;
        }

        private static int Next()
        {
            int c;
            int res = 0;
            do
            {
                c = reader.Read();
                if (c == -1)
                    return res;
            } while (c < '0' || c > '9');
            res = c - '0';
            while (true)
            {
                c = reader.Read();
                if (c < '0' || c > '9')
                    return res;
                res *= 10;
                res += c - '0';
            }
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Codeforces {
    static int[] F;
    static void Main(String[] args) {
#if LOCAL
        Console.SetIn(new System.IO.StreamReader("input"));
#endif

        F = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

        bool valid = false;

        int[] rep1 = { 12, 13, 4, 5, 16, 17, 20, 21 };
        int[] rep2 = { 14, 15, 6, 7, 18, 19, 22, 23 };
        int[] rep3 = { 0, 2, 4, 6, 8, 10, 23, 21 };
        int[] rep4 = { 1, 3, 5, 7, 9, 11, 22, 20 };

        valid = valid || rotate(rep1);
        valid = valid || rotate(rep2);
        valid = valid || rotate(rep3);
        valid = valid || rotate(rep4);

        Console.WriteLine(valid ? "YES" : "NO");
    }

    private static bool rotate(int[] rep) {
        int[] f2 = new int[24];

        for (int i = 0; i < 24; i++) f2[i] = F[i];
        for (int i = 0; i < 8; i++) {
            f2[rep[i]] = F[rep[(8 + i - 2) % 8]];
        }

        int[] f3 = new int[24];

        for (int i = 0; i < 24; i++) f3[i] = F[i];
        for (int i = 0; i < 8; i++) {
            f3[rep[i]] = F[rep[(i + 2) % 8]];
        }

        return check(f2) || check(f3);
    }

    private static bool check(int[] F) {
        for (int i = 0; i < F.Length; i += 4) {
            if (!(F[i] == F[i + 1] && F[i] == F[i + 2] && F[i] == F[i + 3])) return false;
        }
        return true;
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

namespace CF
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            using (var sr = new InputReader(Console.In))
//			using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
                //using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;
        private readonly TextWriter sw;
        private bool isDispose;

        public Task(InputReader sr, TextWriter sw)
        {
            this.sr = sr;
            this.sw = sw;
        }

        public void Solve()
        {
            const int max = 25;
            var input = sr.ReadArrayOfInt32();
            var colors = new int[max];
            for (var i = 1; i < max; i++) {
                colors[i] = input[i - 1];
            }
            if (Check(Move1(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move2(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move3(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move4(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move5(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move6(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move7(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move8(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move9(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move10(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move11(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move12(colors))) {
                sw.WriteLine("YES");
                return;
            }

            sw.WriteLine("NO");
        }

        private int[] Move1(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[2] = colors[6];
            result[4] = colors[8];

            result[6] = colors[10];
            result[8] = colors[12];

            result[10] = colors[23];
            result[12] = colors[21];

            result[21] = colors[4];
            result[23] = colors[2];

            result[18] = colors[17];
            result[20] = colors[18];
            result[19] = colors[20];
            result[17] = colors[19];

            return result;
        }

        private int[] Move2(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[2] = colors[23];
            result[4] = colors[21];

            result[6] = colors[2];
            result[8] = colors[4];

            result[10] = colors[6];
            result[12] = colors[8];

            result[21] = colors[12];
            result[23] = colors[10];

            result[18] = colors[20];
            result[20] = colors[19];
            result[19] = colors[17];
            result[17] = colors[18];

            return result;
        }

        private int[] Move3(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[1] = colors[5];
            result[3] = colors[7];

            result[6] = colors[9];
            result[7] = colors[11];

            result[9] = colors[24];
            result[11] = colors[22];

            result[22] = colors[3];
            result[24] = colors[1];

            result[14] = colors[16];
            result[16] = colors[15];
            result[15] = colors[13];
            result[13] = colors[14];

            return result;
        }

        private int[] Move4(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[1] = colors[24];
            result[3] = colors[22];

            result[5] = colors[1];
            result[7] = colors[3];

            result[9] = colors[5];
            result[11] = colors[7];

            result[22] = colors[11];
            result[24] = colors[9];

            result[14] = colors[13];
            result[16] = colors[14];
            result[15] = colors[16];
            result[13] = colors[15];

            return result;
        }

        private int[] Move5(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[13] = colors[5];
            result[14] = colors[6];

            result[5] = colors[17];
            result[6] = colors[18];

            result[17] = colors[21];
            result[18] = colors[22];

            result[21] = colors[13];
            result[22] = colors[14];

            result[4] = colors[3];
            result[2] = colors[4];
            result[1] = colors[2];
            result[3] = colors[1];

            return result;
        }

        private int[] Move6(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[22] = colors[14];
            result[21] = colors[13];

            result[14] = colors[5];
            result[13] = colors[6];

            result[5] = colors[17];
            result[6] = colors[18];

            result[17] = colors[21];
            result[18] = colors[22];

            result[3] = colors[4];
            result[4] = colors[2];
            result[2] = colors[1];
            result[1] = colors[3];

            return result;
        }

        private int[] Move7(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[15] = colors[7];
            result[16] = colors[8];

            result[7] = colors[19];
            result[8] = colors[20];

            result[19] = colors[23];
            result[20] = colors[24];

            result[23] = colors[15];
            result[24] = colors[16];

            result[10] = colors[9];
            result[12] = colors[10];
            result[11] = colors[12];
            result[9] = colors[11];

            return result;
        }

        private int[] Move8(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[24] = colors[16];
            result[23] = colors[15];

            result[16] = colors[7];
            result[15] = colors[8];

            result[7] = colors[19];
            result[8] = colors[20];

            result[19] = colors[23];
            result[20] = colors[24];

            result[9] = colors[10];
            result[10] = colors[12];
            result[12] = colors[11];
            result[11] = colors[9];

            return result;
        }

        private int[] Move9(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[16] = colors[3];
            result[14] = colors[4];

            result[10] = colors[16];
            result[9] = colors[14];

            result[17] = colors[10];
            result[19] = colors[9];

            result[3] = colors[17];
            result[4] = colors[19];

            result[5] = colors[6];
            result[6] = colors[8];
            result[8] = colors[7];
            result[7] = colors[5];

            return result;
        }

        private int[] Move10(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[3] = colors[16];
            result[4] = colors[14];

            result[16] = colors[10];
            result[14] = colors[9];

            result[10] = colors[17];
            result[9] = colors[19];

            result[17] = colors[3];
            result[4] = colors[19];

            result[6] = colors[5];
            result[8] = colors[6];
            result[7] = colors[8];
            result[5] = colors[7];

            return result;
        }

        private int[] Move11(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[15] = colors[1];
            result[13] = colors[2];

            result[12] = colors[15];
            result[11] = colors[13];

            result[18] = colors[12];
            result[20] = colors[11];

            result[1] = colors[18];
            result[2] = colors[20];

            result[21] = colors[23];
            result[22] = colors[21];
            result[24] = colors[22];
            result[23] = colors[24];

            return result;
        }

        private int[] Move12(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[1] = colors[15];
            result[2] = colors[13];

            result[15] = colors[12];
            result[13] = colors[11];

            result[12] = colors[18];
            result[11] = colors[20];

            result[18] = colors[1];
            result[20] = colors[2];

            result[23] = colors[21];
            result[21] = colors[22];
            result[22] = colors[24];
            result[24] = colors[23];

            return result;
        }

        private bool Check(int[] colors)
        {
            for (var i = 0; i < 6; i++) {
                var startIndx = i * 4 + 1;
                if (colors[startIndx] == colors[startIndx + 1] && colors[startIndx] == colors[startIndx + 2]
                    && colors[startIndx] == colors[startIndx + 2] && colors[startIndx] == colors[startIndx + 3]) {
                    return true;
                }
            }

            return false;
        }

        ~Task()
        {
            Dispose(false);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

namespace CF
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            using (var sr = new InputReader(Console.In))
//			using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
                //using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;
        private readonly TextWriter sw;
        private bool isDispose;

        public Task(InputReader sr, TextWriter sw)
        {
            this.sr = sr;
            this.sw = sw;
        }

        public void Solve()
        {
            const int max = 25;
            var input = sr.ReadArrayOfInt32();
            var colors = new int[max];
            for (var i = 1; i < max; i++) {
                colors[i] = input[i - 1];
            }
            if (Check(Move1(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move2(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move3(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move4(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move5(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move6(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move7(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move8(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move9(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move10(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move11(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move12(colors))) {
                sw.WriteLine("YES");
                return;
            }

            sw.WriteLine("NO");
        }

        private int[] Move1(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[2] = colors[6];
            result[4] = colors[8];

            result[6] = colors[10];
            result[8] = colors[12];

            result[10] = colors[23];
            result[12] = colors[21];

            result[21] = colors[4];
            result[23] = colors[2];

            result[18] = colors[17];
            result[20] = colors[18];
            result[19] = colors[20];
            result[17] = colors[19];

            return result;
        }

        private int[] Move2(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[2] = colors[23];
            result[4] = colors[21];

            result[6] = colors[2];
            result[8] = colors[4];

            result[10] = colors[6];
            result[12] = colors[8];

            result[21] = colors[12];
            result[23] = colors[10];

            result[18] = colors[20];
            result[20] = colors[19];
            result[19] = colors[17];
            result[17] = colors[18];

            return result;
        }

        private int[] Move3(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[1] = colors[5];
            result[3] = colors[7];

            result[6] = colors[9];
            result[7] = colors[11];

            result[9] = colors[22];
            result[11] = colors[24];

            result[22] = colors[3];
            result[24] = colors[1];

            result[14] = colors[16];
            result[16] = colors[15];
            result[15] = colors[13];
            result[13] = colors[14];

            return result;
        }

        private int[] Move4(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[1] = colors[24];
            result[3] = colors[22];

            result[5] = colors[1];
            result[7] = colors[3];

            result[9] = colors[5];
            result[11] = colors[7];

            result[22] = colors[11];
            result[24] = colors[9];

            result[14] = colors[13];
            result[16] = colors[14];
            result[15] = colors[16];
            result[13] = colors[15];

            return result;
        }

        private int[] Move5(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[13] = colors[5];
            result[14] = colors[6];

            result[5] = colors[17];
            result[6] = colors[18];

            result[17] = colors[21];
            result[18] = colors[22];

            result[21] = colors[13];
            result[22] = colors[14];

            result[4] = colors[3];
            result[2] = colors[4];
            result[1] = colors[2];
            result[3] = colors[1];

            return result;
        }

        private int[] Move6(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[22] = colors[14];
            result[21] = colors[13];

            result[14] = colors[5];
            result[13] = colors[6];

            result[5] = colors[17];
            result[6] = colors[18];

            result[17] = colors[21];
            result[18] = colors[22];

            result[3] = colors[4];
            result[4] = colors[2];
            result[2] = colors[1];
            result[1] = colors[3];

            return result;
        }

        private int[] Move7(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[15] = colors[7];
            result[16] = colors[8];

            result[7] = colors[19];
            result[8] = colors[20];

            result[19] = colors[23];
            result[20] = colors[24];

            result[23] = colors[15];
            result[24] = colors[16];

            result[10] = colors[9];
            result[12] = colors[10];
            result[11] = colors[12];
            result[9] = colors[11];

            return result;
        }

        private int[] Move8(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[24] = colors[16];
            result[23] = colors[15];

            result[16] = colors[7];
            result[15] = colors[8];

            result[7] = colors[19];
            result[8] = colors[20];

            result[19] = colors[23];
            result[20] = colors[24];

            result[9] = colors[10];
            result[10] = colors[12];
            result[12] = colors[11];
            result[11] = colors[9];

            return result;
        }

        private int[] Move9(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[16] = colors[3];
            result[14] = colors[4];

            result[10] = colors[16];
            result[9] = colors[14];

            result[17] = colors[10];
            result[19] = colors[9];

            result[3] = colors[17];
            result[4] = colors[19];

            result[5] = colors[6];
            result[6] = colors[8];
            result[8] = colors[7];
            result[7] = colors[5];

            return result;
        }

        private int[] Move10(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[3] = colors[16];
            result[4] = colors[14];

            result[16] = colors[10];
            result[14] = colors[9];

            result[10] = colors[17];
            result[9] = colors[19];

            result[17] = colors[3];
            result[4] = colors[19];

            result[6] = colors[5];
            result[8] = colors[6];
            result[7] = colors[8];
            result[5] = colors[7];

            return result;
        }

        private int[] Move11(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[15] = colors[1];
            result[13] = colors[2];

            result[12] = colors[15];
            result[11] = colors[13];

            result[18] = colors[12];
            result[20] = colors[11];

            result[1] = colors[18];
            result[2] = colors[20];

            result[21] = colors[23];
            result[22] = colors[21];
            result[24] = colors[22];
            result[23] = colors[24];

            return result;
        }

        private int[] Move12(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[1] = colors[15];
            result[2] = colors[13];

            result[15] = colors[12];
            result[13] = colors[11];

            result[12] = colors[18];
            result[11] = colors[20];

            result[18] = colors[1];
            result[20] = colors[2];

            result[23] = colors[21];
            result[21] = colors[22];
            result[22] = colors[24];
            result[24] = colors[23];

            return result;
        }

        private bool Check(int[] colors)
        {
            for (var i = 0; i < 6; i++) {
                var startIndx = i * 4 + 1;
                if (colors[startIndx] == colors[startIndx + 1] && colors[startIndx] == colors[startIndx + 2]
                    && colors[startIndx] == colors[startIndx + 2] && colors[startIndx] == colors[startIndx + 3]) {
                    return true;
                }
            }

            return false;
        }

        ~Task()
        {
            Dispose(false);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

namespace CF
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            using (var sr = new InputReader(Console.In))
//			using (var sr = new InputReader(new StreamReader("input.txt")))
            using (var sw = Console.Out)
                //using (var sw = new StreamWriter("output.txt"))
            using (var task = new Task(sr, sw)) {
                task.Solve();
//                Console.ReadKey();
            }
        }
    }

    internal class Task : IDisposable
    {
        private readonly InputReader sr;
        private readonly TextWriter sw;
        private bool isDispose;

        public Task(InputReader sr, TextWriter sw)
        {
            this.sr = sr;
            this.sw = sw;
        }

        public void Solve()
        {
            const int max = 25;
            var input = sr.ReadArrayOfInt32();
            var colors = new int[max];
            for (var i = 1; i < max; i++) {
                colors[i] = input[i - 1];
            }
            if (Check(Move1(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move2(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move3(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move4(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move5(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move6(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move7(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move8(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move9(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move10(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move11(colors))) {
                sw.WriteLine("YES");
                return;
            }
            if (Check(Move12(colors))) {
                sw.WriteLine("YES");
                return;
            }

            sw.WriteLine("NO");
        }

        private int[] Move1(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[2] = colors[6];
            result[4] = colors[8];

            result[6] = colors[10];
            result[8] = colors[12];

            result[10] = colors[23];
            result[12] = colors[21];

            result[21] = colors[4];
            result[23] = colors[2];

            result[18] = colors[17];
            result[20] = colors[18];
            result[19] = colors[20];
            result[17] = colors[19];

            return result;
        }

        private int[] Move2(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[2] = colors[23];
            result[4] = colors[21];

            result[6] = colors[2];
            result[8] = colors[4];

            result[10] = colors[6];
            result[12] = colors[8];

            result[21] = colors[12];
            result[23] = colors[10];

            result[18] = colors[20];
            result[20] = colors[19];
            result[19] = colors[17];
            result[17] = colors[18];

            return result;
        }

        private int[] Move3(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[1] = colors[5];
            result[3] = colors[7];

            result[6] = colors[9];
            result[7] = colors[11];

            result[9] = colors[22];
            result[11] = colors[24];

            result[22] = colors[3];
            result[24] = colors[1];

            result[14] = colors[16];
            result[16] = colors[15];
            result[15] = colors[13];
            result[13] = colors[14];

            return result;
        }

        private int[] Move4(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[1] = colors[24];
            result[3] = colors[22];

            result[5] = colors[1];
            result[7] = colors[3];

            result[9] = colors[5];
            result[11] = colors[7];

            result[22] = colors[11];
            result[24] = colors[9];

            result[14] = colors[13];
            result[16] = colors[14];
            result[15] = colors[16];
            result[13] = colors[15];

            return result;
        }

        private int[] Move5(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[13] = colors[5];
            result[14] = colors[6];

            result[5] = colors[17];
            result[6] = colors[18];

            result[17] = colors[21];
            result[18] = colors[22];

            result[21] = colors[13];
            result[22] = colors[14];

            result[3] = colors[4];
            result[1] = colors[3];
            result[2] = colors[1];
            result[4] = colors[2];

            return result;
        }

        private int[] Move6(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[22] = colors[14];
            result[21] = colors[13];

            result[14] = colors[5];
            result[13] = colors[6];

            result[5] = colors[17];
            result[6] = colors[18];

            result[17] = colors[21];
            result[18] = colors[22];

            result[2] = colors[4];
            result[1] = colors[2];
            result[3] = colors[1];
            result[4] = colors[3];

            return result;
        }

        private int[] Move7(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[15] = colors[7];
            result[16] = colors[8];

            result[7] = colors[19];
            result[8] = colors[20];

            result[19] = colors[23];
            result[20] = colors[24];

            result[23] = colors[15];
            result[24] = colors[16];

            result[9] = colors[10];
            result[10] = colors[12];
            result[12] = colors[11];
            result[11] = colors[9];

            return result;
        }

        private int[] Move8(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[24] = colors[16];
            result[23] = colors[15];

            result[16] = colors[7];
            result[15] = colors[8];

            result[7] = colors[19];
            result[8] = colors[20];

            result[19] = colors[23];
            result[20] = colors[24];

            result[9] = colors[11];
            result[10] = colors[9];
            result[12] = colors[10];
            result[11] = colors[12];

            return result;
        }

        private int[] Move9(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[16] = colors[3];
            result[14] = colors[4];

            result[10] = colors[16];
            result[9] = colors[14];

            result[17] = colors[10];
            result[19] = colors[9];

            result[3] = colors[17];
            result[4] = colors[19];

            result[5] = colors[6];
            result[6] = colors[8];
            result[8] = colors[7];
            result[7] = colors[5];

            return result;
        }

        private int[] Move10(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[3] = colors[16];
            result[4] = colors[14];

            result[16] = colors[10];
            result[14] = colors[9];

            result[10] = colors[17];
            result[9] = colors[19];

            result[17] = colors[3];
            result[4] = colors[19];

            result[6] = colors[5];
            result[8] = colors[6];
            result[7] = colors[8];
            result[5] = colors[7];

            return result;
        }

        private int[] Move11(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[15] = colors[1];
            result[13] = colors[2];

            result[12] = colors[15];
            result[11] = colors[13];

            result[18] = colors[12];
            result[20] = colors[11];

            result[1] = colors[18];
            result[2] = colors[20];

            result[21] = colors[23];
            result[22] = colors[21];
            result[24] = colors[22];
            result[23] = colors[24];

            return result;
        }

        private int[] Move12(int[] colors)
        {
            var result = (int[]) colors.Clone();

            result[1] = colors[15];
            result[2] = colors[13];

            result[15] = colors[12];
            result[13] = colors[11];

            result[12] = colors[18];
            result[11] = colors[20];

            result[18] = colors[1];
            result[20] = colors[2];

            result[23] = colors[21];
            result[21] = colors[22];
            result[22] = colors[24];
            result[24] = colors[23];

            return result;
        }

        private bool Check(int[] colors)
        {
            for (var i = 0; i < 6; i++) {
                var startIndx = i * 4 + 1;
                if (colors[startIndx] == colors[startIndx + 1] && colors[startIndx] == colors[startIndx + 2]
                    && colors[startIndx] == colors[startIndx + 2] && colors[startIndx] == colors[startIndx + 3]) {
                    return true;
                }
            }

            return false;
        }

        ~Task()
        {
            Dispose(false);
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private void Dispose(bool disposing)
        {
            if (!isDispose) {
                if (disposing) {
                    if(sr != null)
                        sr.Dispose();

                    if(sw != null)
                        sw.Dispose();
                }

                isDispose = true;
            }
        }
    }
}

internal class InputReader : IDisposable
{
    private bool isDispose;
    private readonly TextReader sr;
    private string[] buffer;
    private int seek;

    public InputReader(TextReader stream)
    {
        sr = stream;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    public string NextString()
    {
        var result = sr.ReadLine();
        return result;
    }

    public int NextInt32()
    {
        return Int32.Parse(ReadNextToken());
    }

    private string ReadNextToken()
    {
        if (buffer == null || seek == buffer.Length) {
            seek = 0;
            buffer = NextSplitStrings();
        }

        return buffer[seek++];
    }

    public long NextInt64()
    {
        return Int64.Parse(ReadNextToken());
    }

    public int[] ReadArrayOfInt32()
    {
        return ReadArray(Int32.Parse);
    }

    public long[] ReadArrayOfInt64()
    {
        return ReadArray(Int64.Parse);
    }

    public string[] NextSplitStrings()
    {
        return NextString()
            .Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    }

    public T[] ReadArray<T>(Func<string, CultureInfo, T> func)
    {
        return NextSplitStrings()
            .Select(s => func(s, CultureInfo.InvariantCulture))
            .ToArray();
    }

    public T[] ReadArrayFromString<T>(Func<string, CultureInfo, T> func, string str)
    {
        return
            str.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(s => func(s, CultureInfo.InvariantCulture))
                .ToArray();
    }

    protected void Dispose(bool dispose)
    {
        if (!isDispose)
        {
            if (dispose)
                sr.Close();

            isDispose = true;
        }
    }

    ~InputReader()
    {
        Dispose(false);
    }
}

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

   public class C
    {
          static  bool checkOk(int s , int [] inputs)
        {
            int c = inputs[s*4];
            for(int i = 0;i<4; i++)
            {
                if (c != inputs[s * 4 + i])
                    return false;
            }

            return true;
        }

        static bool  checkRotation(int [,] arr, int [] inp ,int aindex )
        {

            int[] farr = new int[8];
            int[] sarr = new int[8];
            int fp=0, sp = 0;
            for(int  i = 1; i < 9; i++)
            {
                farr[fp++] =  inp[arr[aindex,i]];
                sarr[sp++] = inp[arr[aindex+1, i]];
            }

            bool  checkR = false;
            for(int  i = 0; i < 8; i++)
            {
                if (farr[i] != sarr[(i + 2) % 8])
                    checkR=true;

            }

            if (!checkR)
                return true;

            for (int i = 0; i < 8; i++)
            {
                if (farr[i] != sarr[(i - 2+8) % 8])
                    return false;

            }

            return true;
        }

        static void Main(string[] args)
        {
            int[,] arr = { { 0, 12, 13,4,5,16,17,20,21 },{ 2,14,15,6,7,18,19,22,23}, { 1,1,0,12,14,10,11,23,21 }, { 5,3,2,13,15,8,9,18,16}, { 3, 0,2,4,6,8,10,23,21} ,{ 4,1,3,5,7,9,11,22,20} };

            string inp = Console.ReadLine();
            int[] inputs = new int[24];
            string[] splits = inp.Split(' ');

            for(int i  =0; i < 24; i++)
            {
                inputs[i] = int.Parse(splits[i]);
            }
            bool isPoss = false;
            for(int  i =0; i<6; i+=2)
            {
                if(checkOk(arr[i,0], inputs) && checkOk(arr[i+1, 0], inputs))
                {

                 isPoss  =  checkRotation(arr, inputs, i);
                    break;
                }

            }
            if(isPoss)
                        Console.Write("YES");
                    else
                        Console.Write("NO");

        }
    }

using System;

namespace BT887C
{
    class Program
    {
        static void Main(string[] args)
        {
            const int faceSize = 4;
            const int faceNum = 6;

            int[] arr = new int[faceNum * faceSize];

            string input = Console.ReadLine();

            string[] splitRes = input.Split(' ');
            for (int i = 0; i < faceSize * faceNum; i++)
            {
                var item = splitRes[i];
                arr[i] = int.Parse(item);
            }
            int[,] cir;
            if (IsCompleteFace(arr, 0) && IsCompleteFace(arr, 2))
            {
                cir = toListArr(arr, faceSize * 3, faceSize * 1, faceSize * 4, faceSize * 5);
            }
            else if (IsCompleteFace(arr, 1) && IsCompleteFace(arr, 5))
            {
                RotateLeft(arr, faceSize * 0);
                RotateLeft(arr, faceSize * 0);

                RotateRight(arr, faceSize * 3);

                RotateLeft(arr, faceSize * 4);

                cir = toListArr(arr, faceSize * 0, faceSize * 3, faceSize * 2, faceSize * 4);

            }
            else if (IsCompleteFace(arr, 3) && IsCompleteFace(arr, 4))
            {
                RotateRight(arr, faceSize * 0);
                RotateRight(arr, faceSize * 1);
                RotateRight(arr, faceSize * 2);
                RotateByRightDiagonal(arr, faceSize * 5);
                cir = toListArr(arr, faceSize * 0, faceSize * 1, faceSize * 2, faceSize * 5);
            }
            else
            {
                Console.WriteLine(returnString(false));
                return;
            }

            int index = 0;
            bool result = false;
            for (int i = 1; i < 8; i++)
            {
                if (cir[0, 0] == cir[1, i] && ((8 - i <= 2 && i <= 2)))
                {
                    index = i;
                    bool flag = true;
                    for (int j = 0; j < 8; j++)
                    {
                        if (cir[0, j] != cir[1, ((index + j) % 8)])
                            flag = false;
                    }
                    if (flag == true)
                    {
                        result = true;
                        break;
                    }
                }
            }

            Console.WriteLine(returnString(result));
            return;

        }

        static int[,] toListArr(int[] arr, int index1, int index2, int index3, int index4)
        {
            int[,] returnArr = new int[2, 8];
            returnArr[0, 0] = arr[index1];
            returnArr[0, 1] = arr[index1 + 1];
            returnArr[0, 2] = arr[index2];
            returnArr[0, 3] = arr[index2 + 1];
            returnArr[0, 4] = arr[index3];
            returnArr[0, 5] = arr[index3 + 1];
            returnArr[0, 6] = arr[index4];
            returnArr[0, 7] = arr[index4 + 1];
            returnArr[1, 0] = arr[index1 + 2];
            returnArr[1, 1] = arr[index1 + 3];
            returnArr[1, 2] = arr[index2 + 2];
            returnArr[1, 3] = arr[index2 + 3];
            returnArr[1, 4] = arr[index3 + 2];
            returnArr[1, 5] = arr[index3 + 3];
            returnArr[1, 6] = arr[index4 + 2];
            returnArr[1, 7] = arr[index4 + 3];

            return returnArr;
        }

        static void RotateLeft(int[] arr, int startIndex)
        {
            int temp = arr[startIndex];
            arr[startIndex] = arr[startIndex + 2];
            arr[startIndex + 2] = arr[startIndex + 3];
            arr[startIndex + 3] = arr[startIndex + 1];
            arr[startIndex + 1] = temp;

        }

        static void RotateRight(int[] arr, int startIndex)
        {
            int temp = arr[startIndex];
            arr[startIndex] = arr[startIndex + 1];
            arr[startIndex + 1] = arr[startIndex + 3];
            arr[startIndex + 3] = arr[startIndex + 2];
            arr[startIndex + 2] = temp;
        }

        static void RotateByRightDiagonal(int[] arr, int startIndex)
        {
            int temp = arr[startIndex + 1];
            arr[startIndex + 1] = arr[startIndex + 2];
            arr[startIndex + 2] = temp;

        }

        //static void RotateDown(int[] arr, int startIndex)
        //{
        //    int temp = arr[startIndex];
        //    arr[startIndex] = arr[startIndex + 2];
        //    arr[startIndex + 1] = arr[startIndex];
        //    arr[startIndex + 2] = arr[startIndex + 3];
        //    arr[startIndex + 3] = arr[startIndex + 1];
        //}

        static bool IsCompleteFace(int[] face, int faceIndex)
        {
            const int faceSize = 4;

            int pattern = face[faceIndex * faceSize];
            for (int i = 0; i < faceSize; i++)
            {
                if (face[faceIndex * faceSize + i] != pattern)
                    return false;
            }
            return true;
        }

        static string returnString(bool res)
        {
            if (res)
                return "YES";
            else
                return "NO";
        }
    }
}

using System;

namespace BT887C
{
    class Program
    {
        static void Main(string[] args)
        {
            const int faceSize = 4;
            const int faceNum = 6;

            int[] arr = new int[faceNum * faceSize];

            string input = Console.ReadLine();

            string[] splitRes = input.Split(' ');
            for (int i = 0; i < faceSize * faceNum; i++)
            {
                var item = splitRes[i];
                arr[i] = int.Parse(item);
            }
            int[,] cir;
            if (IsCompleteFace(arr, 0) && IsCompleteFace(arr, 2))
            {
                cir = toListArr(arr, faceSize * 3, faceSize * 1, faceSize * 4, faceSize * 5);
            }
            else if (IsCompleteFace(arr, 1) && IsCompleteFace(arr, 5))
            {
                RotateLeft(arr, faceSize * 0);
                RotateLeft(arr, faceSize * 0);

                RotateRight(arr, faceSize * 3);

                RotateLeft(arr, faceSize * 4);

                cir = toListArr(arr, faceSize * 0, faceSize * 3, faceSize * 2, faceSize * 4);

            }
            else if (IsCompleteFace(arr, 3) && IsCompleteFace(arr, 4))
            {
                RotateRight(arr, faceSize * 0);
                RotateRight(arr, faceSize * 1);
                RotateRight(arr, faceSize * 2);
                RotateByRightDiagonal(arr, faceSize * 5);
                cir = toListArr(arr, faceSize * 0, faceSize * 1, faceSize * 2, faceSize * 5);
            }
            else
            {
                Console.WriteLine(returnString(false));
                return;
            }

            int index = 0;
            bool result = false;
            for (int i = 0; i < 8; i++)
            {
                if (cir[0, 0] == cir[1, i])
                {
                    index = i;
                    bool flag = true;
                    for (int j = 0; j < 8; j++)
                    {
                        if (cir[0, j] != cir[1, ((index + j) % 8)])
                            flag = false;
                    }
                    if (flag == true)
                    {
                        result = true;
                        break;
                    }
                }
            }

            Console.WriteLine(returnString(result));
            return;

        }

        static int[,] toListArr(int[] arr, int index1, int index2, int index3, int index4)
        {
            int[,] returnArr = new int[2, 8];
            returnArr[0, 0] = arr[index1];
            returnArr[0, 1] = arr[index1 + 1];
            returnArr[0, 2] = arr[index2];
            returnArr[0, 3] = arr[index2 + 1];
            returnArr[0, 4] = arr[index3];
            returnArr[0, 5] = arr[index3 + 1];
            returnArr[0, 6] = arr[index4];
            returnArr[0, 7] = arr[index4 + 1];
            returnArr[1, 0] = arr[index1 + 2];
            returnArr[1, 1] = arr[index1 + 3];
            returnArr[1, 2] = arr[index2 + 2];
            returnArr[1, 3] = arr[index2 + 3];
            returnArr[1, 4] = arr[index3 + 2];
            returnArr[1, 5] = arr[index3 + 3];
            returnArr[1, 6] = arr[index4 + 2];
            returnArr[1, 7] = arr[index4 + 3];

            return returnArr;
        }

        static void RotateLeft(int[] arr, int startIndex)
        {
            int temp = arr[startIndex];
            arr[startIndex] = arr[startIndex + 2];
            arr[startIndex + 2] = arr[startIndex + 3];
            arr[startIndex + 3] = arr[startIndex + 1];
            arr[startIndex + 1] = temp;

        }

        static void RotateRight(int[] arr, int startIndex)
        {
            int temp = arr[startIndex];
            arr[startIndex] = arr[startIndex + 1];
            arr[startIndex + 1] = arr[startIndex + 3];
            arr[startIndex + 3] = arr[startIndex + 2];
            arr[startIndex + 2] = temp;
        }

        static void RotateByRightDiagonal(int[] arr, int startIndex)
        {
            int temp = arr[startIndex + 1];
            arr[startIndex + 1] = arr[startIndex + 2];
            arr[startIndex + 2] = temp;

        }

        //static void RotateDown(int[] arr, int startIndex)
        //{
        //    int temp = arr[startIndex];
        //    arr[startIndex] = arr[startIndex + 2];
        //    arr[startIndex + 1] = arr[startIndex];
        //    arr[startIndex + 2] = arr[startIndex + 3];
        //    arr[startIndex + 3] = arr[startIndex + 1];
        //}

        static bool IsCompleteFace(int[] face, int faceIndex)
        {
            const int faceSize = 4;

            int pattern = face[faceIndex * faceSize];
            for (int i = 0; i < faceSize; i++)
            {
                if (face[faceIndex * faceSize + i] != pattern)
                    return false;
            }
            return true;
        }

        static string returnString(bool res)
        {
            if (res)
                return "YES";
            else
                return "NO";
        }
    }
}

using System;

namespace BT887C
{
    class Program
    {
        static void Main(string[] args)
        {
            const int faceSize = 4;
            const int faceNum = 6;

            int[] arr = new int[faceNum * faceSize];

            string input = Console.ReadLine();

            string[] splitRes = input.Split(' ');
            for (int i = 0; i < faceSize * faceNum; i++)
            {
                var item = splitRes[i];
                arr[i] = int.Parse(item);
            }
            int[,] cir;
            if (IsCompleteFace(arr, 0) && IsCompleteFace(arr, 2))
            {
                cir = toListArr(arr, faceSize * 3, faceSize * 1, faceSize * 4, faceSize * 5);
            }
            else if (IsCompleteFace(arr, 1) && IsCompleteFace(arr, 5))
            {
                RotateLeft(arr, faceSize * 0);
                RotateLeft(arr, faceSize * 0);

                RotateRight(arr, faceSize * 3);

                RotateLeft(arr, faceSize * 4);

                cir = toListArr(arr, faceSize * 0, faceSize * 3, faceSize * 2, faceSize * 4);

            }
            else if (IsCompleteFace(arr, 3) && IsCompleteFace(arr, 4))
            {
                RotateRight(arr, faceSize * 0);
                RotateRight(arr, faceSize * 1);
                RotateRight(arr, faceSize * 2);
                RotateByRightDiagonal(arr, faceSize * 5);
                cir = toListArr(arr, faceSize * 0, faceSize * 1, faceSize * 2, faceSize * 5);
            }
            else
            {
                Console.WriteLine(returnString(false));
                return;
            }

            int index = 0;
            bool result = false;
            for (int i = 1; i < 8; i++)
            {
                if (cir[0, 0] == cir[1, i])
                {
                    index = i;
                    bool flag = true;
                    for (int j = 0; j < 8; j++)
                    {
                        if (cir[0, j] != cir[1, ((index + j) % 8)])
                            flag = false;
                    }
                    if (flag == true)
                    {
                        result = true;
                        break;
                    }
                }
            }

            Console.WriteLine(returnString(result));
            return;

        }

        static int[,] toListArr(int[] arr, int index1, int index2, int index3, int index4)
        {
            int[,] returnArr = new int[2, 8];
            returnArr[0, 0] = arr[index1];
            returnArr[0, 1] = arr[index1 + 1];
            returnArr[0, 2] = arr[index2];
            returnArr[0, 3] = arr[index2 + 1];
            returnArr[0, 4] = arr[index3];
            returnArr[0, 5] = arr[index3 + 1];
            returnArr[0, 6] = arr[index4];
            returnArr[0, 7] = arr[index4 + 1];
            returnArr[1, 0] = arr[index1 + 2];
            returnArr[1, 1] = arr[index1 + 3];
            returnArr[1, 2] = arr[index2 + 2];
            returnArr[1, 3] = arr[index2 + 3];
            returnArr[1, 4] = arr[index3 + 2];
            returnArr[1, 5] = arr[index3 + 3];
            returnArr[1, 6] = arr[index4 + 2];
            returnArr[1, 7] = arr[index4 + 3];

            return returnArr;
        }

        static void RotateLeft(int[] arr, int startIndex)
        {
            int temp = arr[startIndex];
            arr[startIndex] = arr[startIndex + 2];
            arr[startIndex + 2] = arr[startIndex + 3];
            arr[startIndex + 3] = arr[startIndex + 1];
            arr[startIndex + 1] = temp;

        }

        static void RotateRight(int[] arr, int startIndex)
        {
            int temp = arr[startIndex];
            arr[startIndex] = arr[startIndex + 1];
            arr[startIndex + 1] = arr[startIndex + 3];
            arr[startIndex + 3] = arr[startIndex + 2];
            arr[startIndex + 2] = temp;
        }

        static void RotateByRightDiagonal(int[] arr, int startIndex)
        {
            int temp = arr[startIndex + 1];
            arr[startIndex + 1] = arr[startIndex + 2];
            arr[startIndex + 2] = temp;

        }

        //static void RotateDown(int[] arr, int startIndex)
        //{
        //    int temp = arr[startIndex];
        //    arr[startIndex] = arr[startIndex + 2];
        //    arr[startIndex + 1] = arr[startIndex];
        //    arr[startIndex + 2] = arr[startIndex + 3];
        //    arr[startIndex + 3] = arr[startIndex + 1];
        //}

        static bool IsCompleteFace(int[] face, int faceIndex)
        {
            const int faceSize = 4;

            int pattern = face[faceIndex * faceSize];
            for (int i = 0; i < faceSize; i++)
            {
                if (face[faceIndex * faceSize + i] != pattern)
                    return false;
            }
            return true;
        }

        static string returnString(bool res)
        {
            if (res)
                return "YES";
            else
                return "NO";
        }
    }
}

using System;

namespace BT887C
{
    class Program
    {
        static void Main(string[] args)
        {
            const int faceSize = 4;
            const int faceNum = 6;

            int[] arr = new int[faceNum * faceSize];

            string input = Console.ReadLine();

            string[] splitRes = input.Split(' ');
            for (int i = 0; i < faceSize * faceNum; i++)
            {
                var item = splitRes[i];
                arr[i] = int.Parse(item);
            }
            int[,] cir;
            if (IsCompleteFace(arr, 0) && IsCompleteFace(arr, 2))
            {
                cir = toListArr(arr, faceSize, faceSize * 3, faceSize * 4, faceSize * 5);
            }
            else if (IsCompleteFace(arr, 1) && IsCompleteFace(arr, 5))
            {
                RotateLeft(arr, faceSize * 0);
                RotateLeft(arr, faceSize * 0);

                RotateRight(arr, faceSize * 3);

                RotateLeft(arr, faceSize * 4);

                cir = toListArr(arr, faceSize * 0, faceSize * 3, faceSize * 2, faceSize * 4);

            }
            else if (IsCompleteFace(arr, 3) && IsCompleteFace(arr, 4))
            {
                RotateRight(arr, faceSize * 0);
                RotateRight(arr, faceSize * 1);
                RotateRight(arr, faceSize * 2);
                RotateByRightDiagonal(arr, faceSize * 5);
                cir = toListArr(arr, faceSize * 0, faceSize * 1, faceSize * 2, faceSize * 5);
            }
            else
            {
                Console.WriteLine(returnString(false));
                return;
            }

            int index = 0;
            bool result = false;
            for (int i = 0; i < 8; i++)
            {
                if (cir[0, 0] == cir[1, i])
                {
                    index = i;
                    bool flag = true;
                    for (int j = 0; j < 8; j++)
                    {
                        if (cir[0, j] != cir[1, ((index + j) % 8)])
                            flag = false;
                    }
                    if (flag == true)
                    {
                        result = true;
                        break;
                    }
                }
            }

            Console.WriteLine(returnString(result));
            return;

        }

        static int[,] toListArr(int[] arr, int index1, int index2, int index3, int index4)
        {
            int[,] returnArr = new int[2, 8];
            returnArr[0, 0] = arr[index1];
            returnArr[0, 1] = arr[index1 + 1];
            returnArr[0, 2] = arr[index2];
            returnArr[0, 3] = arr[index2 + 1];
            returnArr[0, 4] = arr[index3];
            returnArr[0, 5] = arr[index3 + 1];
            returnArr[0, 6] = arr[index4];
            returnArr[0, 7] = arr[index4 + 1];
            returnArr[1, 0] = arr[index1 + 2];
            returnArr[1, 1] = arr[index1 + 3];
            returnArr[1, 2] = arr[index2 + 2];
            returnArr[1, 3] = arr[index2 + 3];
            returnArr[1, 4] = arr[index3 + 2];
            returnArr[1, 5] = arr[index3 + 3];
            returnArr[1, 6] = arr[index4 + 2];
            returnArr[1, 7] = arr[index4 + 3];

            return returnArr;
        }

        static void RotateLeft(int[] arr, int startIndex)
        {
            int temp = arr[startIndex];
            arr[startIndex] = arr[startIndex + 2];
            arr[startIndex + 2] = arr[startIndex + 3];
            arr[startIndex + 3] = arr[startIndex + 1];
            arr[startIndex + 1] = temp;

        }

        static void RotateRight(int[] arr, int startIndex)
        {
            int temp = arr[startIndex];
            arr[startIndex] = arr[startIndex + 1];
            arr[startIndex + 1] = arr[startIndex + 3];
            arr[startIndex + 3] = arr[startIndex + 2];
            arr[startIndex + 2] = temp;
        }

        static void RotateByRightDiagonal(int[] arr, int startIndex)
        {
            int temp = arr[startIndex + 1];
            arr[startIndex + 1] = arr[startIndex + 2];
            arr[startIndex + 2] = temp;

        }

        //static void RotateDown(int[] arr, int startIndex)
        //{
        //    int temp = arr[startIndex];
        //    arr[startIndex] = arr[startIndex + 2];
        //    arr[startIndex + 1] = arr[startIndex];
        //    arr[startIndex + 2] = arr[startIndex + 3];
        //    arr[startIndex + 3] = arr[startIndex + 1];
        //}

        static bool IsCompleteFace(int[] face, int faceIndex)
        {
            const int faceSize = 4;

            int pattern = face[faceIndex * faceSize];
            for (int i = 0; i < faceSize; i++)
            {
                if (face[faceIndex * faceSize + i] != pattern)
                    return false;
            }
            return true;
        }

        static string returnString(bool res)
        {
            if (res)
                return "YES";
            else
                return "NO";
        }
    }
}

using System;

namespace BT887C
{
    class Program
    {
        static void Main(string[] args)
        {
            const int faceSize = 4;
            const int faceNum = 6;

            int[] arr = new int[faceNum * faceSize];

            string input = Console.ReadLine();

            string[] splitRes = input.Split(' ');
            for (int i = 0; i <  faceSize*faceNum; i++)
            {
                var item = splitRes[i];
                arr[i] = int.Parse(item);
            }
            int[,] cir;
            if (IsCompleteFace(arr,0) && IsCompleteFace(arr,2))
            {
                cir = toListArr(arr, faceSize, faceSize * 3, faceSize * 4, faceSize * 5);
            } else if (IsCompleteFace(arr, 1) && IsCompleteFace(arr, 5))
            {
                RotateLeft(arr, faceSize * 0);
                RotateLeft(arr, faceSize * 0);

                RotateRight(arr, faceSize * 3);

                RotateLeft(arr, faceSize * 4);

                cir = toListArr(arr, faceSize * 0, faceSize * 2, faceSize * 3, faceSize * 4);

            }
            else if (IsCompleteFace(arr, 3) && IsCompleteFace(arr, 4))
            {
                RotateRight(arr, faceSize * 0);
                RotateRight(arr, faceSize * 1);
                RotateRight(arr, faceSize * 2);
                RotateByRightDiagonal(arr, faceSize * 5);
                cir = toListArr(arr, faceSize * 0, faceSize * 1, faceSize * 2, faceSize * 5);
            }
            else
            {
                Console.WriteLine(returnString(false));
                return;
            }

            int index = 0;
            bool result = false;
            for(int i = 0; i < 8; i++)
            {
                if(cir[0,0] == cir[1,i])
                {
                    index = i;
                    bool flag = true;
                    for(int j = 0; j < 8; j++)
                    {
                        if (cir[0, j] != cir[1, ((index + j) % 8)])
                            flag = false;
                    }
                    if(flag == true)
                    {
                        result = true;
                        break;
                    }
                }
            }

            Console.WriteLine(returnString(result));
            return;

        }

        static int[,] toListArr(int[] arr, int index1, int index2, int index3, int index4)
        {
            int[,] returnArr = new int[2,8];
            returnArr[0,0] = arr[index1];
            returnArr[0,1] = arr[index1 + 1];
            returnArr[0,2] = arr[index2];
            returnArr[0,3] = arr[index2 + 1];
            returnArr[0,4] = arr[index3];
            returnArr[0,5] = arr[index3 + 1];
            returnArr[0,6] = arr[index4];
            returnArr[0,7] = arr[index4 + 1];
            returnArr[1,0] = arr[index1 + 2];
            returnArr[1,1] = arr[index1 + 3];
            returnArr[1,2] = arr[index2 + 2];
            returnArr[1,3] = arr[index2 + 3];
            returnArr[1,4] = arr[index3 + 2];
            returnArr[1,5] = arr[index3 + 3];
            returnArr[1,6] = arr[index4 + 2];
            returnArr[1,7] = arr[index4 + 3];

            return returnArr;
        }

        static void RotateLeft(int[] arr, int startIndex)
        {
            int temp = arr[startIndex];
            arr[startIndex] = arr[startIndex + 2];
            arr[startIndex + 2] = arr[startIndex + 3];
            arr[startIndex + 3] = arr[startIndex + 1];
            arr[startIndex + 1] = temp;

        }

        static void RotateRight(int[] arr, int startIndex)
        {
            int temp = arr[startIndex];
            arr[startIndex] = arr[startIndex + 1];
            arr[startIndex + 1] = arr[startIndex + 3];
            arr[startIndex + 3] = arr[startIndex + 2];
            arr[startIndex + 2] = temp;
        }

        static void RotateByRightDiagonal(int[] arr, int startIndex)
        {
            int temp = arr[startIndex + 1];
            arr[startIndex + 1] = arr[startIndex + 2];
            arr[startIndex + 2] = temp;

        }

        //static void RotateDown(int[] arr, int startIndex)
        //{
        //    int temp = arr[startIndex];
        //    arr[startIndex] = arr[startIndex + 2];
        //    arr[startIndex + 1] = arr[startIndex];
        //    arr[startIndex + 2] = arr[startIndex + 3];
        //    arr[startIndex + 3] = arr[startIndex + 1];
        //}

        static bool IsCompleteFace(int[] face,  int faceIndex)
        {
            const int faceSize = 4;

            int pattern = face[faceIndex*faceSize];
            for (int i = 0; i < faceSize; i++)
            {
                if (face[faceIndex * faceSize + i] != pattern)
                    return false;
            }
            return true;
        }

        static string returnString(bool res)
        {
            if (res)
                return "YES";
            else
                return "NO";
        }
    }
}

using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using System.IO;
public class CodeForces
{
#if TEST
// To set this go to Project -> Properties -> Build -> General -> Conditional compilation symbols: -> enter 'TEST' into text box.
const bool testing = true;
#else
    const bool testing = true;
#endif

    static void program(TextReader input)
    {
        var s = input.ReadLine().Split(' ').Select(int.Parse).ToList();

        var trans = new List<List<int>>() {
            new List<int>(){1,3,5,7,9,11,24,22},
            new List<int>(){2,4,6,8,10,12,23,21},
            new List<int>(){13,14,5,6,17,18,21,22},
            new List<int>(){15,16,7,8,19,20,23,24},
            new List<int>(){15,16,7,8,19,20,23,24},
            new List<int>(){14,3,4,17,19,10,9,16},
            new List<int>(){13,1,2,18,20,12,11,15}
        };

        for(var i = 0; i < trans.Count; i++)
        {
            var newS = s.ToList();
            for(var j = 0; j < trans[i].Count; j++)
            {
                newS[trans[i][j] - 1] = s[trans[i][(j + 2) % 8] - 1];
            }

            var pos = true;
            for(var k = 0; k < 5; k++)
            {
                var color = newS[k * 4];
                for(var j = k * 4 + 1; j < (k + 1) * 4; j++)
                {
                    if(newS[j] != color)
                    {
                        pos = false;
                    }
                }
            }

            if (pos)
            {
                Console.WriteLine("YES");
                return;
            }
        }

        Console.WriteLine("NO");

    }

    public static void Main(string[] args)
    {
        if (!testing)
        { // set testing to false when submiting to codeforces
            program(Console.In); // write your program in 'program' function (its your new main !)
            return;
        }

        Console.WriteLine("Test Case(1) => expected :");
        Console.WriteLine("NO");
        Console.WriteLine("Test Case(1) => found    :");
        program(new StringReader("2 5 4 6 1 3 6 2 5 5 1 2 3 5 3 1 1 2 4 6 6 4 3 4\n"));
        Console.WriteLine();

        Console.WriteLine("Test Case(2) => expected :");
        Console.WriteLine("YES");
        Console.WriteLine("Test Case(2) => found    :");
        program(new StringReader("5 3 5 3 2 5 2 5 6 2 6 2 4 4 4 4 1 1 1 1 6 3 6 3\n"));
        Console.WriteLine();

    }
}

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    int[] a;
    int[] Parse(string s)
    {
        return s.Split(',').Select(ss => a[int.Parse(ss) - 1]).ToArray();
    }

    bool Fun(string left, string right, string c1, string c2)
    {
        var l = Parse(left);
        var r = Parse(right);
        var v1 = Parse(c1);
        var v2 = Parse(c2);
        if (l.Distinct().Count() > 1 || r.Distinct().Count() > 1)
            return false;

        for (int i = 0; i < 8; i += 2)
            if (v1[i] != v1[i + 1])
                return false;

        bool f = true;
        for (int i = 0; i < 8; i++)
            if (v1[i] != v2[(i + 2) % 8])
                f = false;
        if (f)
            return true;
        f = true;
        for (int i = 0; i < 8; i++)
            if (v1[i] != v2[(i + 6) % 8])
                f = false;
        return f;
    }

    public void Solve()
    {
        a = ReadIntArray();

        Write(Fun("13,14,15,16", "17,18,19,20", "1,3,5,7,9,11,24,22", "2,4,6,8,10,12,23,21") ||
            Fun("1,2,3,4", "9,10,11,12", "13,14,5,6,17,18,21,22", "15,16,7,8,19,20,23,24") ||
            Fun("5,6,7,8", "21,22,23,24", "3,4,17,19,10,9,16,14", "1,2,18,20,12,11,16,14") ? "YES" : "NO");
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            new Solver().Solve();
            //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}