#include <iostream>
#include <vector>
#include <string>

#define INPUT_FROM_FILE (0)
#if INPUT_FROM_FILE
#include <fstream>
#endif

enum Face{
	TOP,
	SOUTH,
	EAST,
	WEST,
	NORTH,
	BOTTOM,
};

class Dice{
private:
	std::vector<int> faces_;	

public:
	Dice(const std::vector<int> &labels);

	~Dice();

	void roll_north();

	void roll_east();

	void roll_west();

	void roll_south();

	void roll_left();

	void roll_right();

	void roll_to(char d);

	int get_cur_label(char f);

	bool operator ==(Dice &r);
};

Dice::Dice(const std::vector<int> &labels) : faces_(labels){
	return;
}

Dice::~Dice(){
	return;
}

void Dice::roll_north(){
	int tmp = faces_[TOP];
	faces_[TOP] = faces_[SOUTH];
	faces_[SOUTH] = faces_[BOTTOM];
	faces_[BOTTOM] = faces_[NORTH];
	faces_[NORTH] = tmp;
	return;
}

void Dice::roll_east(){
	int tmp = faces_[TOP];
	faces_[TOP] = faces_[WEST];
	faces_[WEST] = faces_[BOTTOM];
	faces_[BOTTOM] = faces_[EAST];
	faces_[EAST] = tmp;
	return;
}

void Dice::roll_west(){
	int tmp = faces_[TOP];
	faces_[TOP] = faces_[EAST];
	faces_[EAST] = faces_[BOTTOM];
	faces_[BOTTOM] = faces_[WEST];
	faces_[WEST] = tmp;
	return;
}

void Dice::roll_south(){
	int tmp = faces_[TOP];
	faces_[TOP] = faces_[NORTH];
	faces_[NORTH] = faces_[BOTTOM];
	faces_[BOTTOM] = faces_[SOUTH];
	faces_[SOUTH] = tmp;
	return;
}

void Dice::roll_left(){
	int tmp = faces_[SOUTH];
	faces_[SOUTH] = faces_[WEST];
	faces_[WEST] = faces_[NORTH];
	faces_[NORTH] = faces_[EAST];
	faces_[EAST] = tmp;
	return;
}

void Dice::roll_right(){
	int tmp = faces_[SOUTH];
	faces_[SOUTH] = faces_[EAST];
	faces_[EAST] = faces_[NORTH];
	faces_[NORTH] = faces_[WEST];
	faces_[WEST] = tmp;
	return;
}
void Dice::roll_to(char d){
	switch(d){
	case 'N':
		roll_north();
		break;
	case 'E':
		roll_east();
		break;
	case 'W':
		roll_west();
		break;
	case 'S':
		roll_south();
		break;
	case 'R':
		roll_right();
		break;
	case 'L':
		roll_left();
		break;
	default:
		break;
	}
	return;
}

int Dice::get_cur_label(char f){
	return faces_[f];
}

bool Dice::operator==(Dice &r){
	return this->faces_ == r.faces_;
}

bool is_already_searched(Dice dice, std::vector<Dice> &is_searched){
	bool ret = false;

	for(unsigned int i = 0; i < is_searched.size(); i++){
		if(dice == is_searched[i]){
			ret = true;
		}
	}

	return ret;
}

bool is_same(Dice dice0, Dice dice1, std::vector<Dice> &is_searched){
	bool ret = false;
	Dice tmp_dice = dice1;

	if(dice0 == dice1){ return true; }

	tmp_dice.roll_north();
	if(!is_already_searched(tmp_dice, is_searched)){
		is_searched.push_back(tmp_dice);
		ret = is_same(dice0, tmp_dice, is_searched);
	}

	if(!ret){
		tmp_dice = dice1;
		tmp_dice.roll_east();
		if(!is_already_searched(tmp_dice, is_searched)){
			is_searched.push_back(tmp_dice);
			ret = is_same(dice0, tmp_dice, is_searched);
		}
	}

	if(!ret){
		tmp_dice = dice1;
		tmp_dice.roll_south();
		if(!is_already_searched(tmp_dice, is_searched)){
			is_searched.push_back(tmp_dice);
			ret = is_same(dice0, tmp_dice, is_searched);
		}
	}

	if(!ret){
		tmp_dice = dice1;
		tmp_dice.roll_west();
		if(!is_already_searched(tmp_dice, is_searched)){
			is_searched.push_back(tmp_dice);
			ret = is_same(dice0, tmp_dice, is_searched);
		}
	}
	return ret;
}

int main(int argc, char **argv){
#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
#endif
	int num_faces = 6;
	std::vector<int> labels0(num_faces, 0);
	std::vector<int> labels1(num_faces, 0);
	std::string operations;
	int q = 0;

	for(int i = 0; i < num_faces; i++){
#if INPUT_FROM_FILE
		ifs >> labels0[i];
#else
		std::cin >> labels0[i];
#endif;
	}

	for(int i = 0; i < num_faces; i++){
#if INPUT_FROM_FILE
		ifs >> labels1[i];
#else
		std::cin >> labels1[i];
#endif;
	}

	Dice dice0(labels0);
	Dice dice1(labels1);
	std::vector<Dice> is_searched;

	if(is_same(dice0, dice1, is_searched)){
		std::cout << "Yes";
	}
	else{
		std::cout << "No";
	}
	std::cout << std::endl;

	return 0;
}



Measured memory_bytes: 3156