#include <iostream>
using namespace std;

struct dice {
	int top;
	int bottom;
	int north;
	int east;
	int south;
	int west;
};


class Dice {
	public:
		void init(int i, int j, int k, int l, int m, int n);
		void order(char order);
		struct dice dice_s;
		void north();
		void east();
		void south();
		void west();
		void right();
		void left();
};

void Dice::init(int i, int j, int k, int l, int m, int n)
{
	dice_s.top = i;
	dice_s.bottom = n;
	dice_s.south = j;
	dice_s.east = k;
	dice_s.west = l;
	dice_s.north = m;

}

void Dice::order(char order)
{

		switch(order) {
			case 'E':
				east();
				break;
			case 'W':
				west();
				break;
			case 'N':
				north();
				break;
			case 'S':
				south();
				break;
			case 'R':
				right();
				break;
			case 'L':
				left();
				break;
			default:
				break;
		}

}

void Dice::east()
{
	int top = dice_s.top;
	int bottom = dice_s.bottom;
	int east = dice_s.east;
	int west = dice_s.west;

	dice_s.top = west;
	dice_s.bottom = east;
	dice_s.east = top;
	dice_s.west = bottom;


}
void Dice::west()
{
	int top = dice_s.top;
	int bottom = dice_s.bottom;
	int east = dice_s.east;
	int west = dice_s.west;

	dice_s.top = east;
	dice_s.bottom = west;
	dice_s.east = bottom;
	dice_s.west = top;


}
void Dice::north()
{
	
	int top = dice_s.top;
	int bottom = dice_s.bottom;
	int north = dice_s.north;
	int south = dice_s.south;

	dice_s.top = south;
	dice_s.bottom = north;
	dice_s.south = bottom;
	dice_s.north = top;

}
void Dice::south()
{
	int top = dice_s.top;
	int bottom = dice_s.bottom;
	int north = dice_s.north;
	int south = dice_s.south;

	dice_s.top = north;
	dice_s.bottom = south;
	dice_s.south = top;
	dice_s.north = bottom;

}

void Dice::right()
{
	
	int north = dice_s.north;
	int south = dice_s.south;
	int west = dice_s.west;
	int east = dice_s.east;

	dice_s.west = south;
	dice_s.east = north;
	dice_s.south = east;
	dice_s.north = west;

}
void Dice::left()
{
	int north = dice_s.north;
	int south = dice_s.south;
	int west = dice_s.west;
	int east = dice_s.east;

	dice_s.west = north;
	dice_s.east = south;
	dice_s.south = west;
	dice_s.north = east;

}
char T_hantei(Dice dice1, Dice dice2)
{
	if (dice1.dice_s.top == dice2.dice_s.top)
		return 'T';
	else if (dice1.dice_s.top == dice2.dice_s.bottom)
		return 'B';
	else if (dice1.dice_s.top == dice2.dice_s.south)
		return 'S';
	else if (dice1.dice_s.top == dice2.dice_s.north)
		return 'N';
	else if (dice1.dice_s.top == dice2.dice_s.west)
		return 'W';
	else if (dice1.dice_s.top == dice2.dice_s.east)
		return 'E';
	else 
		return 'X';
}

char F_hantei(Dice dice1, Dice dice2)
{
	if (dice1.dice_s.south == dice2.dice_s.south)
		return 'F';
	else if (dice1.dice_s.south == dice2.dice_s.east)
		return 'R';
	else if (dice1.dice_s.south == dice2.dice_s.west)
		return 'L';
	else if (dice1.dice_s.south == dice2.dice_s.north)
		return 'B';
	else 
		return 'X';

}


bool hantei(Dice dice1, Dice dice2)
{
	char Top,Front,Right;

	Top = T_hantei(dice1, dice2);
	switch (Top) {
		case 'T':
			break;
		case 'B':
			dice2.order('S');
			dice2.order('S');
			break;
		case 'S':
			dice2.order('N');
			break;
		case 'N':
			dice2.order('S');
			break;
		case 'E':
			dice2.order('W');
			break;
		case 'W':
			dice2.order('E');
			break;
		default:
			return (false);

	}

	Front = F_hantei(dice1, dice2);
	switch (Front) {
		case 'F':
			break;
		case 'R':
			dice2.order('R');
			break;
		case 'L':
			dice2.order('L');
			break;
		case 'B':
			dice2.order('R');
			dice2.order('R');
			break;
		default:
			return (false);
	}

	if (dice1.dice_s.east == dice2.dice_s.east)
		return (true);
	else 
		return (false);

}

int main()
{
	class Dice dice1,dice2;
	int first,second,third,forth,fifth,sixth;
	bool hantei_stat = false;

	cin >> first >> second >> third >> forth >> fifth >> sixth;

	dice1.init(first, second, third, forth, fifth, sixth);

	cin >> first >> second >> third >> forth >> fifth >> sixth;

	dice2.init(first, second, third, forth, fifth, sixth);


	hantei_stat = hantei(dice1, dice2);

	if (hantei_stat)
		cout << "Yes\n";
	else 
		cout << "No\n";

	return 0;
}


Measured memory_bytes: 3108