#include <stdio.h>

//構造体
typedef struct dice
{
	int Upper;
	int South;
	int East;
	int West;
	int North;
	int Under;
} Dice;

//構造体を初期化する
Dice InitDice(void);
//要素を入れ替える
Dice RotateDice(Dice dice);
Dice ChangeNum_East(Dice dice);
Dice ChangeNum_South(Dice dice);
//さいころ１とさいころ２を比較する
int StructCmp(Dice dice1, Dice dice2);
//さいころを動かす
int MoveDice(Dice dice1, Dice dice2, int EorS);

#define diceFace 6

int main(void)
{
	Dice dice1 = InitDice();	//さいころ１
	Dice dice2 = InitDice();	//さいころ２
	int num[diceFace];			//数値を入れる配列
	int i;

	//二つのさいころの値を入力する
	scanf("%d%d%d%d%d%d", &dice1.Upper, &dice1.South, &dice1.East
		, &dice1.West, &dice1.North, &dice1.Under);
	scanf("%d%d%d%d%d%d", &dice2.Upper, &dice2.South, &dice2.East
		, &dice2.West, &dice2.North, &dice2.Under);

	//printf("dice1.Upper : %d || dice2.Upper : %d\n", dice1.Upper, dice2.Upper);
	//printf("dice1.South : %d || dice2.South : %d\n", dice1.South, dice2.South);
	//printf("dice1.East  : %d || dice2.East  : %d\n", dice1.East, dice2.East);
	//printf("dice1.West  : %d || dice2.West  : %d\n", dice1.West, dice2.West);
	//printf("dice1.North : %d |i dice2.North : %d\n", dice1.North, dice2.North);
	//printf("dice1.Under : %d || dice2.Under : %d\n", dice1.Under, dice2.Under);

	if (MoveDice(dice1, dice2, 0) == 1)
	{
		printf("Yes\n");
	}
	else if (MoveDice(dice1, dice2, 1) == 1)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}

//構造体を初期化する
Dice InitDice(void)
{
	Dice di;

	di.Upper = 0;
	di.South = 0;
	di.East = 0;
	di.West = 0;
	di.North = 0;
	di.Under = 0;

	return di;
}

//反時計回りに１面ずつ回転する
Dice RotateDice(Dice dice)
{
	Dice di = InitDice();

	di.Upper = dice.Upper;
	di.South = dice.West;
	di.East = dice.South;
	di.West = dice.North;
	di.North = dice.East;
	di.Under = dice.Under;

	//printf("\tdice.Upper : %d \n", di.Upper);
	//printf("\tdice.South : %d \n", di.South);
	//printf("\tdice.East  : %d \n", di.East);
	//printf("\tdice.West  : %d \n", di.West);
	//printf("\tdice.North : %d \n", di.North);
	//printf("\tdice.Under : %d \n\n", di.Under);
	
	return di;
}

//E方向に転がす
Dice ChangeNum_East(Dice dice)
{
	Dice di = InitDice();

	di.Upper = dice.West;
	di.South = dice.South;
	di.East = dice.Upper;
	di.West = dice.Under;
	di.North = dice.North;
	di.Under = dice.East;

	//printf("\tdice.Upper : %d \n", di.Upper);
	//printf("\tdice.South : %d \n", di.South);
	//printf("\tdice.East  : %d \n", di.East);
	//printf("\tdice.West  : %d \n", di.West);
	//printf("\tdice.North : %d \n", di.North);
	//printf("\tdice.Under : %d \n\n", di.Under);

	return di;
}

//S方向に転がす
Dice ChangeNum_South(Dice dice)
{
	Dice di = InitDice();

	di.Upper = dice.North;
	di.South = dice.Upper;
	di.East = dice.East;
	di.West = dice.West;
	di.North = dice.Under;
	di.Under = dice.South;

	//printf("\tdice.Upper : %d \n", di.Upper);
	//printf("\tdice.South : %d \n", di.South);
	//printf("\tdice.East  : %d \n", di.East);
	//printf("\tdice.West  : %d \n", di.West);
	//printf("\tdice.North : %d \n", di.North);
	//printf("\tdice.Under : %d \n\n", di.Under);
	
	return di;
}

//さいころ１とさいころ２を比較する
int StructCmp(Dice dice1, Dice dice2)
{
	//printf("\tdice1.Upper : %d || dice2.Upper : %d\n", dice1.Upper, dice2.Upper);
	//printf("\tdice1.South : %d || dice2.South : %d\n", dice1.South, dice2.South);
	//printf("\tdice1.East  : %d || dice2.East  : %d\n", dice1.East, dice2.East);
	//printf("\tdice1.West  : %d || dice2.West  : %d\n", dice1.West, dice2.West);
	//printf("\tdice1.North : %d || dice2.North : %d\n", dice1.North, dice2.North);
	//printf("\tdice1.Under : %d || dice2.Under : %d\n\n", dice1.Under, dice2.Under);

	if (dice1.Upper == dice2.Upper)
	{
		if (dice1.South == dice2.South)
		{
			if (dice1.East == dice2.East)
			{
				if (dice1.West == dice2.West)
				{
					if (dice1.North == dice2.North)
					{
						if (dice1.Under == dice2.Under)
						{
							return 1;
						}
						else
						{
							return 0;
						}
					}
					else
					{
						return 0;
					}
				}
				else
				{
					return 0;
				}
			}
			else
			{
				return 0;
			}
		}
		else
		{
			return 0;
		}
	}
	else
	{
		return 0;
	}
}

//さいころを動かす
int MoveDice(Dice dice1, Dice dice2, int EorS)
{
	int operation[] = { 30, 20, 30, 20, 30, 20, 30, 20, 
				    10, 30, 20, 30, 20, 30, 20, 30, 20,
				    10, 30, 20, 30, 20, 30, 20, 30, 20,
				    10, 30, 20, 30, 20, 30, 20, 30, 20,
				    40 };
	int ope = 0;

	//for (int i = 0; operation[i] < 40; i++)
	//	printf("%d ", operation[i]);
	//printf("\n");


	//case 10 : E方向へ１回動かす
	//case 20 : その場で3回回転する
	//case 30 : あっているかチェックする
	while (1)
	{
		switch (operation[ope])
		{
		case 10:
			//printf("case 10 : ope = %d\n", ope);
			if (EorS == 0)
			{
				dice2 = ChangeNum_East(dice2);
			}
			else
			{
				dice2 = ChangeNum_South(dice2);
			}
			++ope;
			break;
		case 20:
			//printf("case 20 : ope = %d\n", ope);
			dice2 = RotateDice(dice2);
			++ope;
			break;
		case 30:
			//printf("case 30 : StructCmp(dice1, dice2) = %d\n        : ope = %d\n", StructCmp(dice1, dice2), ope);
			if (StructCmp(dice1, dice2) == 1)
			{
				return 1;
			}
			else
			{
				++ope;
				break;
			}
		default:
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 2148