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;
class main{
    static void Main(string[] args){
        string[] line = Console.ReadLine().Split(' ');
        string[] line2 = Console.ReadLine().Split(' ');
        int[] numbers = new int[6];
        int[] numbers2 = new int[6];
        for(int i = 0;i<6;i++){
            numbers[i] = int.Parse(line[i]);
            numbers2[i] = int.Parse(line2[i]);
        }
        dice dice = new dice();
        dice.setNumbers(numbers);
        dice dice2 = new dice();
        dice2.setNumbers(numbers2);

        for (int i = 0; i < 6; i++)
        {
            if (dice.T == numbers2[i])
            {
                if (i == 1)
                {
                    dice2.T = numbers2[1];
                    dice2.S = numbers2[5];
                    dice2.N = numbers2[0];
                    dice2.B = numbers2[4];
                }
                else if (i == 2)
                {
                    dice2.T = numbers2[2];
                    dice2.E = numbers2[5];
                    dice2.W = numbers2[0];
                    dice2.B = numbers2[3];
                }
                else if (i == 3)
                {
                    dice2.T = numbers2[3];
                    dice2.E = numbers2[0];
                    dice2.W = numbers2[5];
                    dice2.B = numbers2[2];
                }
                else if (i == 4)
                {
                    dice2.T = numbers2[4];
                    dice2.S = numbers2[0];
                    dice2.N = numbers2[5];
                    dice2.B = numbers2[1];
                }
                else if (i == 5)
                {
                    dice2.E = dice2.W;
                    dice2.W = numbers2[2];
                }
                break;
            }
        }
        if (dice.S == dice2.N)
        {
            int tmp = dice2.N;
            dice2.N = dice2.S;
            dice2.S = tmp;
            tmp = dice2.W;
            dice2.W = dice.E;
            dice.E = tmp;
        }
        else if (dice.S == dice2.E)
        {
            int tmp = dice2.N;
            dice2.N = dice2.W;
            dice2.W = dice2.S;
            dice2.S = dice2.E;
            dice2.E = tmp;
        }
        else if (dice.S == dice2.W)
        {
            int tmp = dice2.N;
            dice2.N = dice2.W;
            dice2.W = dice2.S;
            dice2.S = dice2.E;
            dice2.E = tmp;
        }

        if (dice == dice2)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}
class dice
{
    private int _T, _B, _N, _E, _W, _S;
    public int T { get { return _T; } set { _T = value; } }
    public int B { get { return _B; } set { _B = value; } }
    public int N { get { return _N; } set { _N = value; } }
    public int E { get { return _E; } set { _E = value; } }
    public int W { get { return _W; } set { _W = value; } }
    public int S { get { return _S; } set { _S = value; } }

    public dice(){
        _T= _B= _N= _E= _W= _S = 0;
    }

    public void setNumbers(int[] numbers)
    {
        _T = numbers[0];
        _S = numbers[1];
        _E = numbers[2];
        _W = numbers[3];
        _N = numbers[4];
        _B = numbers[5];
    }
}