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;

namespace ITP1_11_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' ');
            string[] input2 = Console.ReadLine().Split(' ');
            int[] number1 = new int[6];
            int[] number2 = new int[6];

            for (int i = 0; i < 6; i++)
            {
                number1[i] = int.Parse(input1[i]);
                number2[i] = int.Parse(input2[i]);
            }
            Judge judging = new Judge(number1);
            string result = judging.Hantei(number2);
            Console.WriteLine(result);
        }
    }

    class Judge
    {
        public int[] D;
        public Judge(int[] data) //data=number1  基準
        {
            D = data;
        }
        public string Hantei(int[] abc) //abc=number2
        {
            string yes = "Yes";
            string no = "No";
            string result = null;

            int abc0 = abc[0]; //1
            int abc1 = abc[1]; //2
            int abc2 = abc[2]; //3
            int abc3 = abc[3]; //4
            int abc4 = abc[4]; //5
            int abc5 = abc[5]; //6


            
            if (D[0] == abc0 && D[5] == abc5)  //上
            {
                if (D[1] == abc1 && D[4] == abc4)  //前
                {
                    if (D[2] == abc2 && D[3] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[3] == abc0 && D[2] == abc5)  //上
            {
                if (D[1] == abc1 && D[4] == abc4)  //前
                {
                    if (D[0] == abc2 && D[5] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[5] == abc0 && D[0] == abc5)  //上
            {
                if (D[1] == abc1 && D[4] == abc4)  //前
                {
                    if (D[3] == abc2 && D[2] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[2] == abc0 && D[5] == abc5)  //上
            {
                if (D[1] == abc1 && D[4] == abc4)  //前
                {
                    if (D[3] == abc2 && D[0] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }




            if (D[2] == abc0 && D[4] == abc5)  //上
            {
                if (D[5] == abc1 && D[0] == abc4)  //前
                {
                    if (D[3] == abc2 && D[1] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[0] == abc0 && D[4] == abc5)  //上
            {
                if (D[2] == abc1 && D[3] == abc4)  //前
                {
                    if (D[5] == abc2 && D[1] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[3] == abc0 && D[4] == abc5)  //上
            {
                if (D[0] == abc1 && D[5] == abc4)  //前
                {
                    if (D[2] == abc2 && D[1] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[5] == abc0 && D[4] == abc5)  //上
            {
                if (D[3] == abc1 && D[2] == abc4)  //前
                {
                    if (D[0] == abc2 && D[1] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }





            if (D[4] == abc0 && D[0] == abc5)  //上
            {
                if (D[3] == abc1 && D[2] == abc4)  //前
                {
                    if (D[1] == abc2 && D[5] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[4] == abc0 && D[3] == abc5)  //上
            {
                if (D[5] == abc1 && D[0] == abc4)  //前
                {
                    if (D[1] == abc2 && D[2] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[4] == abc0 && D[5] == abc5)  //上
            {
                if (D[2] == abc1 && D[3] == abc4)  //前
                {
                    if (D[1] == abc2 && D[0] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[4] == abc0 && D[2] == abc5)  //上
            {
                if (D[0] == abc1 && D[5] == abc4)  //前
                {
                    if (D[1] == abc2 && D[3] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }



            if (D[0] == abc0 && D[2] == abc5)  //上
            {
                if (D[1] == abc1 && D[4] == abc4)  //前
                {
                    if (D[5] == abc2 && D[3] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[3] == abc0 && D[0] == abc5)  //上
            {
                if (D[1] == abc1 && D[4] == abc4)  //前
                {
                    if (D[2] == abc2 && D[5] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[5] == abc0 && D[3] == abc5)  //上
            {
                if (D[1] == abc1 && D[4] == abc4)  //前
                {
                    if (D[0] == abc2 && D[2] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[2] == abc0 && D[5] == abc5)  //上
            {
                if (D[1] == abc1 && D[4] == abc4)  //前
                {
                    if (D[3] == abc2 && D[0] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }



            if (D[2] == abc0 && D[4] == abc5)  //上
            {
                if (D[5] == abc1 && D[0] == abc4)  //前
                {
                    if (D[3] == abc2 && D[1] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[0] == abc0 && D[4] == abc5)  //上
            {
                if (D[2] == abc1 && D[3] == abc4)  //前
                {
                    if (D[5] == abc2 && D[1] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[3] == abc0 && D[4] == abc5)  //上
            {
                if (D[0] == abc1 && D[5] == abc4)  //前
                {
                    if (D[2] == abc2 && D[1] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[5] == abc0 && D[4] == abc5)  //上
            {
                if (D[3] == abc1 && D[2] == abc4)  //前
                {
                    if (D[0] == abc2 && D[1] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }



            if (D[4] == abc0 && D[0] == abc5)  //上
            {
                if (D[3] == abc1 && D[2] == abc4)  //前
                {
                    if (D[1] == abc2 && D[5] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[4] == abc0 && D[3] == abc5)  //上
            {
                if (D[5] == abc1 && D[0] == abc4)  //前
                {
                    if (D[1] == abc2 && D[2] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[4] == abc0 && D[5] == abc5)  //上
            {
                if (D[2] == abc1 && D[3] == abc4)  //前
                {
                    if (D[1] == abc2 && D[0] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }
            if (D[4] == abc0 && D[2] == abc5)  //上
            {
                if (D[0] == abc1 && D[5] == abc4)  //前
                {
                    if (D[1] == abc2 && D[3] == abc3)  //右
                    {
                        result = yes;
                    }
                }
            }


            if (result == null)
                result = no;

            return result;
        }
    }
}