#include<stdio.h>

#define UP 0
#define FRONT 1
#define RIGHT 2
#define LEFT 3
#define BACK 4
#define BOTTOM 5
#define TILES 6

typedef struct{
	int label[6];		// label, what do each tiles have.
	int direction[6];	// direction, what direction is dice. [0]-[5]:up, front, right, left, back, bottom.
}dice;

int DiceRoll(dice* p, char c);

int main(void){
	dice a, b;
	int i=0, j=0;		// loop index
	int u_content=0;	// b's up content
	int f_content=0;	// b's front content
	int u_label=-1;		// a's label which have same as b's up content
	int f_label=-1;		// a's label which have same as b's front content
	int off_label=-1;

	for(i=0;i<TILES;i++){		// dice direction setup
		a.direction[i]=i;
		b.direction[i]=i;
	}

	scanf("%d %d %d %d %d %d", &a.label[0], &a.label[1],
		&a.label[2], &a.label[3], &a.label[4], &a.label[5]);	// dice label setup
	
	scanf("%d %d %d %d %d %d", &b.label[0], &b.label[1],
		&b.label[2], &b.label[3], &b.label[4], &b.label[5]);	// dice label setup

	u_content = b.label[UP];
	f_content = b.label[FRONT];

	for(j=0;j<TILES;j++){
		if(u_content == a.label[j]) u_label = j;
		if(f_content == a.label[j]) f_label = j;
	}

	if(u_label == -1 || f_label == -1){
		printf("No\n");
		return 0;
	}

	// roll to same up tile
	off_label = a.direction[UP];
	do{
		DiceRoll(&a, 'E');
	}while(a.direction[UP] != off_label && a.direction[UP] != u_label);

	if(a.direction[UP] == off_label){
		while(a.direction[UP] != u_label) DiceRoll(&a, 'N');
	}

	off_label = a.direction[FRONT];
	do{
		DiceRoll(&a, 'R');
	}while(a.direction[FRONT] != f_label && a.direction[FRONT] != off_label);

	if(a.direction[FRONT] == off_label && a.direction[FRONT] != f_label){
		printf("No\n");
		return 0;
	}

	for(i=0;i<TILES;i++){
		if(a.label[a.direction[i]] != b.label[b.direction[i]]){
			printf("No\n");
			return 0;
		}
	}

	printf("Yes\n");
	return 0;
}

int DiceRoll(dice* p, char c){
	int tmp = -1;
	
	switch(c){
	case 'E':
		tmp = p->direction[UP];
		p->direction[UP] = p->direction[LEFT];		// up <- left
		p->direction[LEFT] = p->direction[BOTTOM];	// left <- bottom
		p->direction[BOTTOM] = p->direction[RIGHT];	// bottom <- right
		p->direction[RIGHT] = tmp;					// right <- up
		break;
	case 'N':
		tmp = p->direction[UP];
		p->direction[UP] = p->direction[FRONT];		// up <- front
		p->direction[FRONT] = p->direction[BOTTOM];	// front <- bottom
		p->direction[BOTTOM] = p->direction[BACK];	// bottom <- back
		p->direction[BACK] = tmp;					// back <- up
		break;
	case 'S':
		tmp = p->direction[UP];
		p->direction[UP] = p->direction[BACK];		// up <- back
		p->direction[BACK] = p->direction[BOTTOM];	// back <- bottom
		p->direction[BOTTOM] = p->direction[FRONT];	// bottom <- front
		p->direction[FRONT] = tmp;					// front <- up
		break;
	case 'W':
		tmp = p->direction[UP];
		p->direction[UP] = p->direction[RIGHT];		// up <- right
		p->direction[RIGHT] = p->direction[BOTTOM];	// right <- bottom
		p->direction[BOTTOM] = p->direction[LEFT];	// bottom <- left
		p->direction[LEFT] = tmp;					// left <- up
		break;
	case 'R':
		tmp = p->direction[FRONT];
		p->direction[FRONT] = p->direction[LEFT];	// front <- left
		p->direction[LEFT] = p->direction[BACK];	// left <- back
		p->direction[BACK] = p->direction[RIGHT];	// back <- right
		p->direction[RIGHT] = tmp;					// right <- front
		break;
	case 'L':
		tmp = p->direction[FRONT];
		p->direction[FRONT] = p->direction[RIGHT];	// front <- right
		p->direction[RIGHT] = p->direction[BACK];	// right <- back
		p->direction[BACK] = p->direction[LEFT];	// back <- left
		p->direction[LEFT] = tmp;					// left <- front
		break;
	default:
		break;
	}

	return 0;
}

Measured memory_bytes: 580