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)
	{
      
		string diceAdata = Console.ReadLine();
		string diceBdata = Console.ReadLine();
		string[] diceA = diceAdata.Split();
		string[] diceB = diceBdata.Split();		
	
		string top = diceB[0];
		string bottom = diceB[5];
		string north = diceB[4];
		string south = diceB[1];
		string east = diceB[2];
		string west = diceB[3];
		string temp = "0";
		
		string yesNo = "No";
		
		int index = Array.IndexOf(diceB, diceA[0]);
		
		while (diceA[0] != top) {
				
			switch (index) {
				case 1:
				case 4:
				case 5:
					temp = top;
					top = south;
					south = bottom;
					bottom = north;
					north = temp;
					
					break;
				case 2:
				case 3:					
					temp = top;
					top = east;
					east = bottom;
					bottom = west;
					west = temp;
					
					break;			
			}
		}		
		
		if (diceA[5] == bottom) {	
				
			while (diceA[1] != south) {
				temp = south;
				south = west;
				west = north;
				north = east;
				east = temp;
			
			}
			if (top==diceA[0]&&bottom==diceA[5]&&south==diceA[1]&&east == diceA[2] && north == diceA[4] && west == diceA[3]) {
				yesNo = "Yes";
			}
			
		}			
		Console.WriteLine(yesNo);
	}		
}