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: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Dice_II
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' ');
            string[] input2 = Console.ReadLine().Split(' ');
 
             
                 
 
            Dice dice1 = new Dice(input1);
            Dice dice2 = new Dice(input2);
 
            List<string> result1 = new List<string>();
            List<string> result2 = new List<string>();
            string ctr = " zzzxyyyzxxxzyyyzxxxyzzz";
 
            for (int i = 0; i < ctr.Length; i++)
            {
                dice1.Rotate(ctr[i]);
                for (int j = 0; j < ctr.Length; j++)
                {
                    dice2.Rotate(ctr[j]);
                    if (dice1.top.Equals(dice2.top) && dice1.front.Equals(dice2.front))
                    {
                        if (dice1.right.Equals(dice2.right))
                        {
                            if (dice1.back.Equals(dice2.back))
                            {
                                if (dice1.left.Equals(dice2.left))
                                {
                                    if (dice1.bottom.Equals(dice2.bottom))
                                    {
                                        Console.WriteLine("Yes");
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
 
            }
            Console.WriteLine("No");
             
        }
    }
 
    class Dice
    {
        public string top, front, right, left, back, bottom;
 
        public Dice(string[] input)
        {
            this.top = input[0];
            this.front = input[1];
            this.right = input[2];
            this.left = input[3];
            this.back = input[4];
            this.bottom = input[5];
        }
 
        void RotateX()
        {
            string temp = this.top;
            this.top = this.front;
            this.front = this.bottom;
            this.bottom = this.back;
            this.back = temp;
        }
 
        void RotateY()
        {
            string temp = this.front;
            this.front = this.right;
            this.right = this.back;
            this.back = this.left;
            this.left = temp;
        }
 
        void RotateZ()
        {
            string temp = this.top;
            this.top = this.left;
            this.left = this.bottom;
            this.bottom = this.right;
            this.right = temp;
        }
 
        public void Rotate(char ctr)
        {
            switch (ctr)
            {
                case 'x':
                    RotateX();
                    break;
                case 'y':
                    RotateY();
                    break;
                case 'z':
                    RotateZ();
                    break;
                default:
                    break;
            }
        }
 
    }
}