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[] str1 = Console.ReadLine().Split(' ');
            Dice dice1 = new Dice(int.Parse(str1[0]), int.Parse(str1[1]), int.Parse(str1[2]), int.Parse(str1[3]), int.Parse(str1[4]), int.Parse(str1[5]));

            string[] str2 = Console.ReadLine().Split(' ');
            Dice dice2 = new Dice(int.Parse(str2[0]), int.Parse(str2[1]), int.Parse(str2[2]), int.Parse(str2[3]), int.Parse(str2[4]), int.Parse(str2[5]));

            if (allCheckSame(dice1, dice2)) { Console.WriteLine("Yes"); }
            else { Console.WriteLine("No"); }

        }

        static bool checkSame(Dice dice1,Dice dice2)
        {
            return (true
                && dice1.TopPip == dice2.TopPip
                && dice1.NorthPip == dice2.NorthPip
                && dice1.SouthPip == dice2.SouthPip
                && dice1.WestPip == dice2.WestPip
                && dice1.EastPip == dice2.EastPip
                && dice1.BottomPip == dice2.BottomPip
                );
        }

        static bool revolveCheckSame(Dice dice1,Dice dice2)
        {
            for (int i = 0; i < 4; ++i) 
            {
                if (checkSame(dice1, dice2)) { return true; }
                dice2.RevolveLeft();
            }
            return false;
        }

        static bool allCheckSame(Dice dice1,Dice dice2)
        {
            if (revolveCheckSame(dice1, dice2)) { return true; }

            Dice tempDice = dice2;
            tempDice.MoveEast();
            if (revolveCheckSame(dice1, tempDice)) { return true; }

            tempDice = dice2;
            tempDice.MoveNorth();
            if (revolveCheckSame(dice1, tempDice)) { return true; }

            tempDice = dice2;
            tempDice.MoveSouth();
            if (revolveCheckSame(dice1, tempDice)) { return true; }

            tempDice = dice2;
            tempDice.MoveWest();
            if (revolveCheckSame(dice1, tempDice)) { return true; }

            tempDice = dice2;
            tempDice.MoveNorth();
            tempDice.MoveNorth();
            if (revolveCheckSame(dice1, tempDice)) { return true; }

            return false;


        }
    }

    class Dice
    {
        public int TopPip { get; private set; }
        public int SouthPip { get; private set; }
        public int EastPip { get; private set; }
        public int WestPip { get; private set; }
        public int NorthPip { get; private set; }
        public int BottomPip { get; private set; }

        public Dice(int topPip, int southPip, int eastPip, int westPip, int northPip, int bottomPip)
        {
            this.TopPip = topPip;
            this.SouthPip = southPip;
            this.EastPip = eastPip;
            this.WestPip = westPip;
            this.NorthPip = northPip;
            this.BottomPip = bottomPip;
        }

        public void MoveNorth()
        {
            int temp = this.NorthPip;
            this.NorthPip = this.TopPip;
            this.TopPip = this.SouthPip;
            this.SouthPip = this.BottomPip;
            this.BottomPip = temp;
        }

        public void MoveSouth()
        {
            int temp = this.SouthPip;
            this.SouthPip = this.TopPip;
            this.TopPip = this.NorthPip;
            this.NorthPip = this.BottomPip;
            this.BottomPip = temp;
        }

        public void MoveWest()
        {
            int temp = this.WestPip;
            this.WestPip = this.TopPip;
            this.TopPip = this.EastPip;
            this.EastPip = this.BottomPip;
            this.BottomPip = temp;
        }

        public void MoveEast()
        {
            int temp = this.EastPip;
            this.EastPip = this.TopPip;
            this.TopPip = this.WestPip;
            this.WestPip = this.BottomPip;
            this.BottomPip = temp;
        }

        public void RevolveLeft()
        {
            int temp = this.SouthPip;
            this.SouthPip = this.EastPip;
            this.EastPip = this.NorthPip;
            this.NorthPip = this.WestPip;
            this.WestPip = temp;
        }

        public void SetTop(int topPip)
        {
            while (true)
            {
                if (this.TopPip == topPip) { break; }
                MoveNorth();
                if (this.TopPip == topPip) { break; }
                MoveWest();
            }
        }

        public void SetTop(int topPip, int southPip)
        {
            SetTop(topPip);
            while (true)
            {
                if (this.SouthPip == southPip) { break; }
                RevolveLeft();
            }
        }


    }
}