Problem:
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

Dice III

Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.

Input

In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels.

In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels.

Output

Print "Yes" if two dices are identical, otherwise "No" in a line.

Constraints

$0 \leq $ the integer assigned to a face $ \leq 100$

Sample Input 1

1 2 3 4 5 6
6 2 4 3 5 1

Sample Output 1

Yes

Sample Input 2

1 2 3 4 5 6
6 5 4 3 2 1

Sample Output 2

No

Solution in C# (judge verdict: Wrong Answer)

using System;
using System.Linq;

namespace AOJ
{
    class Program
    {
        
        static void Main(string[] args)
        {
            var read = Console.ReadLine();
            var dice_surface_arry = read.Split();
            var dice_obj1 = new dice(dice_surface_arry);

            read = Console.ReadLine();
            dice_surface_arry = read.Split();
            var dice_ob2 = new dice(dice_surface_arry);

            if (dice_obj1.dice_Comparison(dice_ob2.get_sueface()))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }

    }

    //?????????????????????
    class dice
    {
        //?????????????????¨??¢
        int[] dice_surface = new int [6];
        int[] dice_surface_temp = new int[6];
        
        //??????????????????????????¨??¢??????????????£?????????
        public dice(string[] sueface_temp)
        {
            for(var i=0;i<dice_surface.Length;i++)
            {
                dice_surface[i] = int.Parse(sueface_temp[i]);
            }
        }

        public int[] get_sueface()
        {
            return dice_surface;
        }

        //?????????????????¨?????\??¬????????????????????????
        public int dice_emulate(string order)
        {


            for (var i = 0; i < order.Length;i++ )
            {
                switch(order.Substring(i,1))
                {
                    case"N":
                        {
                            dice_vertical_rotation("up");
                            break;
                        }
                    case "S":
                        {
                            dice_vertical_rotation("down");
                            break;
                        }
                    case"E":
                        {
                            dice_horizone_rotation("right");
                            break;
                        }

                    case"W":
                        {
                            dice_horizone_rotation("left");
                            break;
                        }
                }

            }

                return dice_surface[0];
        }

        //???????????????2??¢?????????????????¨???????????¢???????????????????????????
        public int dice_direction(int up,int front)
        {
            int directio_up=0,direction_front=0;

            //???????????£?????????????????¢????????????
            for (var i = 0; i < dice_surface.Length;i++ )
            {
                if(dice_surface[i]==up)
                {
                    directio_up = i+1;
                }
            }

            for (var i = 0; i < dice_surface.Length; i++)
            {
                if (dice_surface[i] == front)
                {
                    direction_front = i+1;
                }
            }

            //???????????¢??????????????????????????????????????????
            switch (directio_up)
            {
                case 1:
                    {
                        switch(direction_front)
                        {
                            case 2:
                                return dice_surface[2];

                            case 3:
                                return dice_surface[4];

                            case 4:
                                return dice_surface[1];

                            case 5:
                                return dice_surface[3];
                        }

                        break;
                    }
                case 2:
                    {
                        switch (direction_front)
                        {
                            case 1:
                                return dice_surface[3];

                            case 3:
                                return dice_surface[0];

                            case 4:
                                return dice_surface[5];

                            case 6:
                                return dice_surface[2];
                        }
                        break;
                    }
                case 3:
                    {
                        switch (direction_front)
                        {
                            case 1:
                                return dice_surface[1];

                            case 2:
                                return dice_surface[5];

                            case 5:
                                return dice_surface[0];

                            case 6:
                                return dice_surface[4];
                        }
                        break;
                    }

                case 4:
                    {
                        switch (direction_front)
                        {
                            case 1:
                                return dice_surface[4];

                            case 2:
                                return dice_surface[0];

                            case 5:
                                return dice_surface[5];

                            case 6:
                                return dice_surface[1];
                        }
                        break;
                    }
                case 5:
                    {
                        switch (direction_front)
                        {
                            case 1:
                                return dice_surface[2];

                            case 3:
                                return dice_surface[5];

                            case 4:
                                return dice_surface[0];

                            case 6:
                                return dice_surface[3];
                        }
                        break;
                    }
                case 6:
                    {
                        switch (direction_front)
                        {
                            case 2:
                                return dice_surface[3];

                            case 3:
                                return dice_surface[1];

                            case 4:
                                return dice_surface[4];

                            case 5:
                                return dice_surface[2];
                        }
                        break;
                    }
            }

            return 0;

        }

        void dice_horizone_rotation(string course)
        {
            dice_surface_temp[0] = dice_surface[0];
            dice_surface_temp[2] = dice_surface[2];
            dice_surface_temp[3] = dice_surface[3];
            dice_surface_temp[5] = dice_surface[5];

            switch(course)
            {
                case"right":
                    {
                        dice_surface[0] = dice_surface_temp[3];
                        dice_surface[2] = dice_surface_temp[0];
                        dice_surface[3] = dice_surface_temp[5];
                        dice_surface[5] = dice_surface_temp[2];
                        break;
                    }
                case"left":
                    {
                        dice_surface[3] = dice_surface_temp[0];
                        dice_surface[0] = dice_surface_temp[2];
                        dice_surface[5] = dice_surface_temp[3];
                        dice_surface[2] = dice_surface_temp[5];
                        break;
                    }
            }
        }
        void dice_vertical_rotation(string course)
        {
            dice_surface_temp[0] = dice_surface[0];
            dice_surface_temp[1] = dice_surface[1];
            dice_surface_temp[4] = dice_surface[4];
            dice_surface_temp[5] = dice_surface[5];

            switch(course)
            {
                case"up":
                    {
                        

                        dice_surface[4] = dice_surface_temp[0];
                        dice_surface[0] = dice_surface_temp[1];
                        dice_surface[1] = dice_surface_temp[5];
                        dice_surface[5] = dice_surface_temp[4];
                        break;
                    }
                case"down":
                    {

                        dice_surface[0] = dice_surface_temp[4];
                        dice_surface[1] = dice_surface_temp[0];
                        dice_surface[5] = dice_surface_temp[1];
                        dice_surface[4] = dice_surface_temp[5];
                        break;
                    }
            }
        }
        void dice_z_axis_rotation(string coures)
        {
            dice_surface_temp[1] = dice_surface[1];
            dice_surface_temp[2] = dice_surface[2];
            dice_surface_temp[3] = dice_surface[3];
            dice_surface_temp[4] = dice_surface[4];
            switch(coures)
            {
                case"right":
                    {
                        dice_surface[1] = dice_surface_temp[2];
                        dice_surface[2] = dice_surface_temp[4];
                        dice_surface[3] = dice_surface_temp[1];
                        dice_surface[4] = dice_surface_temp[3];
                        break;
                    }
                case"left":
                    {
                        dice_surface[1] = dice_surface_temp[3];
                        dice_surface[2] = dice_surface_temp[1];
                        dice_surface[3] = dice_surface_temp[4];
                        dice_surface[4] = dice_surface_temp[2];
                        break;
                    }
            }
        }

        public bool dice_Comparison(int[] Specimen)
        {
            if(arry_Comparison(Specimen))
            {
                return true;
            }
            for (var j = 0; j < 4; j++)
            {
                dice_z_axis_rotation("left");
                if (arry_Comparison(Specimen))
                {
                    return true;
                }

            }
            for (var i = 0; i < 3; i++)
            {
                dice_horizone_rotation("left");
                for (var j = 0; j < 4; j++)
                {
                    dice_z_axis_rotation("left");
                    if (arry_Comparison(Specimen))
                    {
                        return true;
                    }

                }
            }

            return false;
        }

        bool arry_Comparison(int[] Specimen)
        {
            return dice_surface.SequenceEqual(Specimen);
        }


    }
}