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 ConsoleApplication46
{
    class Program
    {
        static void Main(string[] args)
        {
            //?????????????????????
            string[] input = Console.ReadLine().Split(' ');
            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);
            int c = int.Parse(input[2]);
            int d = int.Parse(input[3]);
            int e = int.Parse(input[4]);
            int f = int.Parse(input[5]);
            //
            string[] input2 = Console.ReadLine().Split(' ');
            int g = int.Parse(input2[0]);
            int h = int.Parse(input2[1]);
            int i = int.Parse(input2[2]);
            int kari = 0; 
            while (true)
            {
                if (g == a)
                {
                    break;
                }
                //zen???a???¨f??????¨???
                if (h == a || h == f)
                {
                    kari = a;
                    a = b;
                    b = f;
                    f = e;
                    e = kari;
                }
                //cut???
                if (h == b || h == e)
                {
                    kari = a;
                    a = d;
                    d = f;
                    f = c;
                    c = kari;
                }
                //
                if (h == c || h == d)
                {
                    kari = a;
                    a = b;
                    b = f;
                    f = e;
                    e = kari;
                }
            }
            //
            while (true)
            {
                if (h == b)
                {
                    break;
                }
                if (g == c || g == d)
                {
                    kari = a;
                    a = e;
                    e = f;
                    f = b;
                    b = kari;
                }
                else if (g == b || g == e)
                {
                    kari = a;
                    a = c;
                    c = f;
                    f = d;
                    d = kari;
                }
                else if (g == a || g == f)
                {
                    kari = b;
                    b = c;
                    c = e;
                    e = d;
                    d = kari;
                }
            }
            if (c == i)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
 
        }
    }
}
//c?????????