//???????????£?¨?
class Dice{
	
public:
	Dice(int top, int front, int right,
		 int left, int back, int bottom);  //?????????????????????(?????°??????)
	int get_top();
	int get_front();
	int get_right();
	int get_left();
	int get_back();
	int get_bottom();
	bool roll_topfront(int top, int front);
	void roll(char r);
	bool equals(Dice &b);
	
private:
	
	bool kakunin_all(Dice b);
	bool roll_top(int top);
	bool roll_front(int front);
	bool kakunin4(int right, int left, int back, int bottom);
	void roll_n();
	void roll_e();
	void roll_s();
	void roll_w();
	int m_top;
	int m_front;
	int m_right;
	int m_left;
	int m_back;
	int m_bottom;
	void show_all();
};
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> Dice_bec;

int main(void)
{
	Dice_bec dice_bec1, dice_bec2;
	int num;
	//????????????????????\???
	for(int i = 0; i < 6; i++){
		cin >> num;
		dice_bec1.push_back(num);
	}
	//????????????2?????\???
	for(int i = 0; i < 6; i++){
		cin >> num;
		dice_bec2.push_back(num);
	}
	
	
	Dice dice1(dice_bec1[0], dice_bec1[1], dice_bec1[2],
			   dice_bec1[3], dice_bec1[4], dice_bec1[5]);  //?????????????????????1
			  
	Dice dice2(dice_bec2[0], dice_bec2[1], dice_bec2[2],
			   dice_bec2[3], dice_bec2[4], dice_bec2[5]); //?????????????????????2
	
	if(dice1.equals(dice2) == true){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	
	return 0;
	
}

Dice::Dice(int top, int front, int right,      //?????????????????????
		   int left, int back, int bottom) :
		   m_top(top), m_front(front), m_right(right),
		   m_left(left), m_back(back), m_bottom(bottom)
{
	//	????????????
}

bool Dice::equals(Dice &b)
{	
	string str = "ESESES";
	for(int i = 0; i < str.size(); i++){
		roll_s();//top???front
		for(int j = 0; j < 4; j++){
			roll_e();
			if(kakunin_all(b) == true){
				return true;
			}
		}
		roll_n();  //front???top
		roll(str[i]);
	}
	return false;
}
bool Dice::kakunin_all(Dice b)
{
	return 
		m_top == b.m_top &&
	    m_front == b.m_front &&
	    m_right == b.m_right &&
	    m_left == b.m_left &&
	    m_back == b.m_back &&
	    m_bottom == b.m_bottom;
}
		

bool Dice::roll_topfront(int top, int front)
{
	if(roll_front(front) == true){
		if(roll_top(top) == true){		
			return true;
		}
	}
	else{
		return false;
	}
	
}

bool Dice::roll_front(int front)
{
	if(front == m_front){
		return true;
	}
	//????????¢
	else if(front == m_top){
		roll_s();
		if(front == m_front){
			return true;
		}
	}
	else if(front == m_back){
		for(int i = 0; i < 2; i++){
			roll_s();
		}
		if(front == m_front){
			return true;
		}
	}
	else if(front == m_bottom){
		roll_n();
		if(front == m_front){
			return true;
		}
	}
	//?¨??????¢
	else if(front == m_right){
		roll_w();
		roll_s();
		if(front == m_front){
			return true;
		}
	}
	else if(front == m_left){
		roll_e();
		roll_s();
	}
	if(front == m_front){
		return true;
	}
	else{
		return false;
	}
}

bool Dice::roll_top(int top)
{
	for(int i = 0; i < 3; i++){
		roll_e();
		if(top == m_top){
			return true;
		}
	}
	return false;
	
}

bool Dice::kakunin4(int right, int left, int back, int bottom)
{
	return ((right == m_right) && (left == m_left) &&
			(back == m_back) && (bottom == m_bottom));
}
void Dice::roll_n()
{
	int temp = m_back;
	
	m_back   = m_top;
	m_top    = m_front;
	m_front  = m_bottom;
	m_bottom = temp;
	
}
void Dice::roll_e()
{
	int temp = m_top;
	
	m_top    = m_left;
	m_left   = m_bottom;
	m_bottom = m_right;
	m_right  = temp;
	
}

void Dice::roll_s()
{
	int temp = m_front;
	
	m_front  = m_top;
	m_top    = m_back;
	m_back   = m_bottom;
	m_bottom = temp;
}

void Dice::roll_w()
{
	int temp = m_left;
	
	m_left   = m_top;
	m_top    = m_right;
	m_right  = m_bottom;
	m_bottom = temp;
}
int Dice::get_top()
{
	return m_top;
}
int Dice::get_front()
{
	return m_front;
}
int Dice::get_right()
{
	return m_right;
}
int Dice::get_left()
{
	return m_left;
}
int Dice::get_back()
{
	return m_back;
}
int Dice::get_bottom()
{
	return m_bottom;
}

void Dice::show_all()
{
	cout << m_top << ' '
		 << m_front << ' '
		 << m_right<< ' '
		 << m_left << ' '
		 << m_back << ' '
		 << m_bottom << ' ' << endl;
}

void Dice::roll(char r)
{
	switch(r){
	case 'N' :
		 roll_n();
		 break;
	case 'E' :
		 roll_e();
		 break;
	case 'S' :
		 roll_s();
		 break;
	case 'W' :
		 roll_w();
		 break;
	}
}

Measured memory_bytes: 3204