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: Accepted)

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

//ITP1_11-C

namespace ConsoleApplication26
{
    class Dice
    {
        int[] DArray1,DArray2;


        public Dice(int[] a,int[] b)
        {
            DArray1 = a;
            DArray2 = b;
        }

        //int[] Copy()
        //{
        //    int[] Di = new int[DArray2.Length];
        //    for (int i = 0; i < DArray2.Length; ++i)
        //    {
        //        Di[i] = DArray2[i];
        //    }
        //    return Di;
        //}

        public int[] DiceRoll(int roll)
        {
            
            switch (roll)
            {
                case 0:
                    break;

                case 1:
                    RollNorth();
                    break;

                case 2:
                    RollWest();
                    break;

                case 3:
                    RollEast();
                    break;

                case 4:
                    RollSouth();
                    break;

                case 5:
                    RollNorth();
                    RollNorth();
                    break;
            }
           // int[] DArray2 = Copy();
            return DArray2;
        }

        void RollNorth()
        {
            int temp;
            temp = DArray2[0];
            DArray2[0] = DArray2[1];
            DArray2[1] = DArray2[5];
            DArray2[5] = DArray2[4];
            DArray2[4] = temp;
        }

        void RollEast()
        {
            int temp;
            temp = DArray2[0];
            DArray2[0] = DArray2[3];
            DArray2[3] = DArray2[5];
            DArray2[5] = DArray2[2];
            DArray2[2] = temp;
        }

        void RollSouth()
        {
            int temp;
            temp = DArray2[0];
            DArray2[0] = DArray2[4];
            DArray2[4] = DArray2[5];
            DArray2[5] = DArray2[1];
            DArray2[1] = temp;
        }

        void RollWest()
        {
            int temp;
            temp = DArray2[0];
            DArray2[0] = DArray2[2];
            DArray2[2] = DArray2[5];
            DArray2[5] = DArray2[3];
            DArray2[3] = temp;
        }

        public int[] DiceRoll2()
        {
            while (DArray1[1] != DArray2[1])
            {
                int temp;
                temp = DArray2[2];
                DArray2[2] = DArray2[1];
                DArray2[1] = DArray2[3];
                DArray2[3] = DArray2[4];
                DArray2[4] = temp;
            }

            return DArray2;
        }


        public bool hantei()            //???????????????????????°????????????????????????
        {
            for (int i = 2; i < 6; ++i)
            {
                if (DArray2[i] != DArray1[i])
                {
                    return false;
                }
            }
            return true;
        }
    }

    

    class Program
    {
        static void Main()
        {
            string[] str1 = Console.ReadLine().Split(' ');
            int[] DiceArray1 = Array.ConvertAll(str1, int.Parse);
            string[] str2 = Console.ReadLine().Split(' ');
            int[] DiceArray2 = Array.ConvertAll(str2, int.Parse);

            bool bl = false;

            Dice DClass = new Dice(DiceArray1,DiceArray2);

            for (int i = 0; i < DiceArray2.Length; ++i)
            {
                if (DiceArray2[i] == DiceArray1[0])
                {
                    DClass.DiceRoll(i);
                    DClass.DiceRoll2();
                    bl = DClass.hantei();

                    if (bl)
                    {
                        Console.WriteLine("Yes");
                        break;
                    }
                   
                }
            }
            if (!bl)
            {
                  Console.WriteLine("No");
            }
           
        }
    }
}