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;

	public class Dice
	{
		public static void Main(String[] args)
		{
			//?????????????????????????????¢????????????????????????????????????????????????
			/*
 			int top=0;
			int bottom=5;
			int north=4;
			int south=1;
			int east=2;
			int west=3;
			int temp=0;
			*/
			string yesNo="No";
			string dataA=Console.ReadLine();
			string dataB=Console.ReadLine();
			string[] diceA=dataA.Split();
			string[] diceB=dataB.Split();
			//string[] ns = {diceB[0],diceB[1],diceB[5],diceB[4]};
			//string[] ew ={diceB[3],diceB[1],diceB[2],diceB[4]};
		//	string[] diceC={ns[0],ns[1],ew[2],ew[0],ew[4],ns[3]};
		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";
						j=10;
						i=10;
						break;
					}
				}
				
				//?????????????¨??????¢
				string temp=diceB[4];
				diceB[4]=diceB[2];
				diceB[2]=diceB[1];
				diceB[1]=diceB[3];
				diceB[3]=temp;
							
				j++;
			}while(j<5);
			//??????????????????????????¢
			string temp2=diceB[4];
			diceB[4]=diceB[5];
			diceB[5]=diceB[1];
			diceB[1]=diceB[0];
			diceB[0]=temp2;
			
			
			i++;
		}while(i<5);
		
			  
			
			Console.WriteLine(yesNo);
					
			
		}
	}