#include <string>
#include <iostream>

using namespace std;

class Dice
{
public:
	static const int SURFACE_NUM = 6; // ?????????????????¢??°
	static const int DIR_NUM = 4; // ?????¢?????????????????°
	static const int ROUND_NUM = 4; // ?????¢????????¢?????°
	enum DIR { N, W, S, E }; // ?????¢??????
private:
	static const int rotate_table[DIR_NUM][ROUND_NUM]; // ?????¢??¨????????¢????????\???????????????
	static const int front_right_rotate_table[ROUND_NUM]; // ?????¢??¨?????¢????????????
	static const int front_top_rotate_table[ROUND_NUM]; // ?????¢??¨?????¢????????????
	int surface_numbers[SURFACE_NUM]; // ??¢?????°???

public:
	Dice(int number[SURFACE_NUM])
	{
		// ??¢?????°???????????????
		for (int i = 0; i < SURFACE_NUM; i++)
			surface_numbers[i] = number[i];
	}
private:
	void rotate(const int table[ROUND_NUM])
	{
		// ????????????????????§????????¢????????¢?????????
		int backup = surface_numbers[table[0]];
		for (int i = 0; i < ROUND_NUM - 1; i++)
			surface_numbers[table[i]] = surface_numbers[table[i + 1]];
		surface_numbers[table[ROUND_NUM - 1]] = backup;
	}
	int *getSurfaceNumber() { return surface_numbers; }
public:
	void rotate(DIR direction)
	{
		// ?????¢????????\????????????????????§?????????
		rotate(rotate_table[direction]);
	}
	bool equals(Dice dice2)
	{
		// ?????¢?????°?????????????????§?????¢????????¢?????????
		for (int i = 0; i < ROUND_NUM; i++) {
			// ????????¢
			if (surface_numbers[0] == dice2.surface_numbers[0]) break;
			rotate(N);
		}
		if (surface_numbers[0] != dice2.surface_numbers[0]) {
			for (int i = 0; i < ROUND_NUM; i++) {
				// ?¨??????¢
				if (surface_numbers[0] == dice2.surface_numbers[0]) break;
				rotate(W);
			}
			// ??????????????????????????£?????´??????false
			if (surface_numbers[0] != dice2.surface_numbers[0]) return false;
		}
		// ?????¢?????°?????????????????§?????¢????????¢?????????
		for (int i = 0; i < ROUND_NUM; i++) {
			// ?¨??????¢
			if (surface_numbers[1] == dice2.surface_numbers[1]) break;
			rotate(front_right_rotate_table);
		}
		if (surface_numbers[1] != dice2.surface_numbers[1]) {
			for (int i = 0; i < ROUND_NUM; i++) {
				// ????????¢
				if (surface_numbers[1] == dice2.surface_numbers[1]) break;
				rotate(front_top_rotate_table);
			}
			// ??????????????????????????£?????´??????false
			if (surface_numbers[1] != dice2.surface_numbers[1]) return false;
		}// ????????¢????????£???????????´??????true
		if (surface_numbers[2] == dice2.surface_numbers[2] &&
			surface_numbers[3] == dice2.surface_numbers[3] &&
			surface_numbers[4] == dice2.surface_numbers[4] &&
			surface_numbers[5] == dice2.surface_numbers[5]) return true;
		// ????????°false
		return false;
	}
};
// ?????¢???????????????????????¢????????¢????????????????????????????????????(?????¢??¨)
const int Dice::rotate_table[DIR_NUM][ROUND_NUM]
{
	{ 0, 1, 5, 4 },
	{ 0, 2, 5, 3 },
	{ 0, 4, 5, 1 },
	{ 0, 3, 5, 2 }
};
// ????????¢????????¢????????????????????????????????????(?????¢??¨)
const int Dice::front_right_rotate_table[ROUND_NUM]{ 1, 2, 4, 3 };
const int Dice::front_top_rotate_table[ROUND_NUM]{ 1, 5, 4, 0 };
int main()
{
	int nums1[Dice::SURFACE_NUM] = { 0 },
		nums2[Dice::SURFACE_NUM] = { 0 };
	for (int i = 0; i < Dice::SURFACE_NUM; i++)
		cin >> nums1[i];
	for (int i = 0; i < Dice::SURFACE_NUM; i++)
		cin >> nums2[i];

	Dice dice1(nums1), dice2(nums2);
	cout << (dice1.equals(dice2) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 1160