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 ConsoleApplication2
{
	using System;

	public class Dice
	{

		public static void Main(String[] args)
		{

			string yesNo = "No";
			string dataA = Console.ReadLine();
			string dataB = Console.ReadLine();
      		string[] diceA = dataA.Split();
     		string[] diceB = 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;
					}
					turn(3, 5, 2, 0, diceB);                   
					j++;
				} while (j < 4);

				if (yesNo == "Yes") {
					break;
				}
				
				j = 0;
				
				if (i == 3) {
                   
					turn(4, 5, 1, 0, diceB);//????????§?????????
					turn(2, 5, 3, 0, diceB);

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

				turn(4, 5, 1, 0, diceB);
				
				i++;
			} while (i < 6);
			
			Console.WriteLine(yesNo);
		}

		public static void 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;
            
		}
	}
}