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;

using System .Linq;


namespace ConsoleApplication2
{
    using System;

    public class Dice
    {

        public static void Main( String[] args )
        {

            string yesNo = "No";
             string dataA = Console .ReadLine();
             string dataB = Console .ReadLine();
         //   string dataA = "1 2 3 4 5 6";
          string[] diceA = dataA .Split();
            // string dataB = "4 5 6 1 2 3";
         //   string dataB = "6 4 5 2 3 1";
              string[] diceB = dataB .Split();

            //test??¨
             //string[] diceA = { "1" , "2" , "3" , "4" , "5" , "6" };
            //string[] diceB = { "6" , "2" , "4" , "3" , "5" , "1" };

            string[] diceTemp =  dataB .Split();
            
              
            string[] diceTemp1 = dataB .Split();

            int i = 0;
            int j = 0;
            do
            {
                do
                {
                    //??????
                    for ( int k = 0 ; k < diceA .Length ; k++ )
                    {
                        if ( !diceA[k] .Equals( diceB[k] ) )
                        {
                            yesNo = "No";
                            break;

                        }
                        if ( k == diceA .Length - 1 )
                        {
                            yesNo = "Yes";

                        }
                    }
                    if ( yesNo == "Yes" )
                    {
                        break;
                    }
                    //?????????????¨??????¢???east??¨??????

                    diceB = turn( 3 , 5 , 2 , 0 , diceB );
                    Console .WriteLine( diceB[1] +"  "+diceB[0]);
                    j++;
                } while ( j < 4 );

                if ( yesNo == "Yes" )
                {
                    break;
                }
                j = 0;
                //??????????????????????????¢ south??¨???


                
                 if ( i == 3 )
                {
                    //east???south
                    diceB = diceTemp;
                    diceB = turn( 2 , 5 , 3 , 0 , diceB );

                    Console .WriteLine( "east"+diceB[1] );
                }
                else if ( i == 4 )
                {
                    //west ???south
                    diceB = diceTemp1;
                    diceB = turn( 3 , 5 , 2 , 0 , diceB );
                    
                    Console .WriteLine( "west"+diceB[1] );
                }

                diceB = turn( 4 , 5 , 1 , 0 , diceB );
             //   Console .WriteLine(diceB[1]);
                i++;
            } while ( i < 6 );



            Console .WriteLine( yesNo );
           Console .ReadLine();


        }

        public static string[] turn( int a , int b , int c , int d , string[] dice )
        {
            string temp = dice[a];
            dice[a] = dice[b];
            dice[b] = dice[c];
            dice[c] = dice[d];
            dice[d] = temp;
            return dice;
        }
    }


}