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 ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' ');
            string[] input2 = Console.ReadLine().Split(' ');
            int c = 0;
            int a0 = int.Parse(input1[0]);
            int a1 = int.Parse(input1[1]);
            int a2 = int.Parse(input1[2]);
            int a3 = int.Parse(input1[3]);
            int a4 = int.Parse(input1[4]);
            int a5 = int.Parse(input1[5]);

            int b0 = int.Parse(input2[0]);
            int b1 = int.Parse(input2[1]);
            int b2 = int.Parse(input2[2]);
            int b3 = int.Parse(input2[3]);
            int b4 = int.Parse(input2[4]);
            int b5 = int.Parse(input2[5]);


            //????????? ????????¢
            for (int i = 0; i < 3; i++)
            {
                if (a0 == b0 && a5 == b5)
                {
                    break;
                }
                else
                { 
                    c = b0;
                    b0 = b1;
                    b1 = b5;
                    b5 = b4;
                    b4 = c;
                }
            }
            //2??????????¨??????¢
            for (int i = 0; i < 3; i++)
            {
                if (a1 == b1 && a4 == b4)
                {
                    break;
                }
                else
                {
                    c = b1;
                    b1 = b2;
                    b2 = b4;
                    b4 = b3;
                    b3 = c;
                }
            }
            if (a0 == b0 && a0 == b0 && a1 == b1 && a2 == b2 && a3 == b3 && a4 == b4 && a5 == b5)
                Console.WriteLine("Yes");
            else
            Console.WriteLine("No");

        }
    }
}