#include<iostream>
#include<string>

using namespace std;

void West(int surface[]);
void East(int surface[]);
void North(int surface[]);
void South(int surface[]);
void Swing(int surface[]);

bool judge(int surface[]);

typedef struct dice {

	int surface[6] = { 0 };
	string str;

} Dice;

Dice memory;
bool change = false;

int main() {

	Dice dice;
	Dice ans;
	int n = 0;
	bool correct = false;

	for (int i = 0; i < 6; i++) {

		cin >> dice.surface[i];

	}

	for (int i = 0; i < 6; i++) {

		cin >> ans.surface[i];

	}

	memory = dice;

	change = true;

	if (judge(ans.surface)) {

		cout << "Yes" << endl;

	}
	else {

		cout << "No" << endl;

	}

	

}

void West(int surface[]) {

	memory.surface[0] = surface[2];
	memory.surface[2] = surface[5];
	memory.surface[5] = surface[3];
	memory.surface[3] = surface[0];

	return;

}

void East(int surface[]) {

	memory.surface[0] = surface[3];
	memory.surface[3] = surface[5];
	memory.surface[5] = surface[2];
	memory.surface[2] = surface[0];

	return;

}

void North(int surface[]) {

	memory.surface[0] = surface[1];
	memory.surface[1] = surface[5];
	memory.surface[5] = surface[4];
	memory.surface[4] = surface[0];

	return;

}

void South(int surface[]) {

	memory.surface[0] = surface[4];
	memory.surface[4] = surface[5];
	memory.surface[5] = surface[1];
	memory.surface[1] = surface[0];

	return;

}

void Swing(int surface[]){

	memory.surface[2] = surface[1];
	memory.surface[1] = surface[3];
	memory.surface[3] = surface[4];
	memory.surface[4] = surface[2];

	return;

}

bool judge(int surface[]) {

	Dice tempo = memory;
	int need[4] = { 0 };
	int arr[3][6] =
	{
		{0,5,1,2,4,3},
		{1,4,0,3,5,2},
		{2,3,0,1,5,4}
	};
	int debug[6] = { 0 };

	for (int i = 0; i < 6; i++) {

		debug[i] = surface[i];

	}

	for (int i = 0; i < 3; i++) {

		if (tempo.surface[arr[i][0]] == surface[arr[0][0]] && tempo.surface[arr[i][1]] == surface[arr[0][1]]) {

			need[0] = arr[i][2];
			need[1] = arr[i][3];
			need[2] = arr[i][4];
			need[3] = arr[i][5];

			for (int u = 0; u < 4; u++) {

				if (tempo.surface[need[(u < 4) ? u : u - 4]] == surface[arr[0][2]] && tempo.surface[need[(u + 1 < 4) ? u + 1 : u + 1 - 4]] == surface[arr[0][3]] && tempo.surface[need[(u + 2 < 4) ? u + 2 : u + 2 - 4]] == surface[arr[0][4]] && tempo.surface[need[(u + 3 < 4) ? u + 3 : u + 3 - 4]] == surface[arr[0][5]]) {

					return true;

				}

				/*switch (i) {

				case 0:
					Swing(tempo.surface);
					break;
				case 1:
					West(tempo.surface);
					break;
				case 2:
					North(tempo.surface);
					break;

				}*/

				tempo = memory;
				
			}

		}
		else if (tempo.surface[arr[i][0]] == surface[arr[0][1]] && tempo.surface[arr[i][1]] == surface[arr[0][0]]) {

			need[0] = arr[i][2];
			need[1] = arr[i][3];
			need[2] = arr[i][4];
			need[3] = arr[i][5];

			for (int u = 0; u < 4; u++) {

				if (tempo.surface[need[(u < 4) ? u : u - 4]] == surface[arr[0][2]] && tempo.surface[need[(u + 1 < 4) ? u + 1 : u + 1 - 4]] == surface[arr[0][5]] && tempo.surface[need[(u + 2 < 4) ? u + 2 : u + 2 - 4]] == surface[arr[0][4]] && tempo.surface[need[(u + 3 < 4) ? u + 3 : u + 3 - 4]] == surface[arr[0][3]]) {

					return true;

				}

				/*switch (i) {

				case 0:
					Swing(tempo.surface);
					break;
				case 1:
					West(tempo.surface);
					break;
				case 2:
					North(tempo.surface);
					break;

				}*/

				tempo = memory;

			}

		}
		else {

			continue;

		}

	}

	return false;

}






Measured memory_bytes: 3164