/* ITP1_11_C */
#include <stdio.h>

#define DEBUG 0

#define MATCHED 1
#define UN_MATCHED 0
#define LAP_1 4

/* ?????¢????????¨????§??????? */
typedef struct {
	short top_surf;
	short front_surf;
	short right_surf;
	short left_surf;
	short back_surf;
	short bottom_surf;
} hexahedron;

/* ?§???????????????????????????? */
void init_dice(hexahedron *data);

/* ?????¢???????????? */
short comp_hexahedron(hexahedron dice1, hexahedron dice2);

/* ?????¢???????????¢????????? */
void rotate(hexahedron *dice, char rotate);

/* N?????????????????¢????????? */
void rotate_N(hexahedron *dice);

/* W?????????????????¢????????? */
void rotate_W(hexahedron *dice);

/* ?????¢??¨?????¢????????????????¨??????????90?°?????¢????????? */
void rotate_clockwise(hexahedron *dice);

/* ?????¢???????????´????????????????¢???? */
short is_match_hexahedron(hexahedron dice1, hexahedron dice2);

/* 2???????§???????????????¢????????¨?????¢??????????????´????????????????????? */
short is_match_top_btm(hexahedron dice1, hexahedron dice2);

/* 2???????§????????????£??¢????????¨?????¢??????????????´????????????????????? */
short is_match_fr_bk(hexahedron dice1, hexahedron dice2);

/* 2???????§???????????????¢????????¨?????¢??????????????´????????????????????? */
short is_match_r_l(hexahedron dice1, hexahedron dice2);

/* ???????????°??¨????§????????????±??¨?????¢??° */
void dbg_show(char *s, hexahedron d)
{
	printf("%s\n", s);
	printf("top_surf = %hd\n", d.top_surf);
	printf("front_surf = %hd\n", d.front_surf);
	printf("right_surf = %hd\n", d.right_surf);
	printf("left_surf = %hd\n", d.left_surf);
	printf("back_surf = %hd\n", d.back_surf);
	printf("bottom_surf = %hd\n", d.bottom_surf);
}

int main(void)
{
	hexahedron dice1, dice2;
	init_dice(&dice1);
	init_dice(&dice2);
	
	scanf("%hd %hd %hd %hd %hd %hd", &dice1.top_surf, &dice1.front_surf,
			&dice1.right_surf, &dice1.left_surf, &dice1.back_surf, &dice1.bottom_surf);
	
	scanf("%hd %hd %hd %hd %hd %hd", &dice2.top_surf, &dice2.front_surf,
			&dice2.right_surf, &dice2.left_surf, &dice2.back_surf, &dice2.bottom_surf);

	// ?????????????????????
	short comp_result = comp_hexahedron(dice1, dice2);
	
	if( MATCHED == comp_result )
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0;
}

/* ?§??????????????????????????????¢??° */
void init_dice(hexahedron *data)
{
	data->top_surf = 0;
	data->front_surf = 0;
	data->right_surf = 0;
	data->left_surf = 0;
	data->back_surf = 0;
	data->bottom_surf = 0;
}

/* ?????¢???????????? */
short comp_hexahedron(hexahedron dice1, hexahedron dice2)
{
	short ii, is_matched = 0;
	// ?????¢??¨?????¢???????????¢?????????
	for( ii = 0; ii < LAP_1; ii++ )
	{
		is_matched = is_match_top_btm(dice1, dice2);
		// ???????????¢????????´??????????¢????
		if( MATCHED == is_matched )
		{
			break;
		}
		// N??????????????¢
		rotate_N(&dice2);
	}
	
	// ?????¢??¨?????¢???????????¢???????????§?????????????????´???
	if( UN_MATCHED == is_matched )
	{
		for( ii = 0; ii < LAP_1; ii++ )
		{
			is_matched = is_match_top_btm(dice1, dice2);
			// ???????????¢????????´??????????¢????
			if( MATCHED == is_matched )
			{
				break;
			}
			// W??????????????¢
			rotate_W(&dice2);
		}
	}
	
	// ?????¢????????¢???????????¢????????¨???????????´???
	if( UN_MATCHED == is_matched )
	{
		return is_matched;
	}
	
	is_matched = UN_MATCHED;
	for( ii = 0; ii < LAP_1; ii++ )
	{
		is_matched = is_match_hexahedron(dice1, dice2);
		// ?????¢????????´??????????¢????
		if( MATCHED == is_matched )
		{
			break;
		}
		// ?????¢??¨?????¢???????????????????¨??????????90?°?????¢?????????
		rotate_clockwise(&dice2);
	}
	
	return is_matched;
}

/*
N?????????????????¢?????????
????????¢????????¢?????????
????????¢????????¢?????????
????????¢?????£??¢?????????
?????£??¢????????¢?????????
????????????????????¢??¨?????¢?????\??????????????????
*/
void rotate_N(hexahedron *dice)
{
	short temp = dice->top_surf;
	dice->top_surf = dice->front_surf;
	dice->front_surf = dice->bottom_surf;
	dice->bottom_surf = dice->back_surf;
	dice->back_surf = temp;
}

/*
W?????????????????¢?????????
????????¢????????¢?????????
????????¢????????¢?????????
????????¢????????¢?????????
????????¢????????¢????????????
?????????????????£??¢??¨?????¢?????\??????????????????
*/
void rotate_W(hexahedron *dice)
{
	short temp = dice->left_surf;
	dice->left_surf = dice->top_surf;
	dice->top_surf = dice->right_surf;
	dice->right_surf = dice->bottom_surf;
	dice->bottom_surf = temp;
}

/*
?????¢??¨?????¢???????????????????¨??????????90?°?????¢?????????
????????¢?????£??¢?????????
?????£??¢????????¢?????????
????????¢????????¢?????????
????????¢????????¢?????????
????????¢??¨?????¢?????\??????????????????
*/
void rotate_clockwise(hexahedron *dice)
{
	short temp = dice->front_surf;
	dice->front_surf = dice->right_surf;
	dice->right_surf = dice->back_surf;
	dice->back_surf = dice->left_surf;
	dice->left_surf = temp;
}

/* ?????¢???????????´????????????????¢???? */
short is_match_hexahedron(hexahedron dice1, hexahedron dice2)
{
#if DEBUG == 1
	dbg_show("dice1", dice1);
	dbg_show("dice2", dice2);
#endif
	
	short comp_result = is_match_top_btm(dice1, dice2);
	// ?????¢????????¢????????´????????????????¢????
	if( UN_MATCHED == comp_result )
	{
		return UN_MATCHED;
	}
	
	comp_result = is_match_r_l(dice1, dice2);
	// ?????¢????????¢????????´????????????????¢????
	if( UN_MATCHED == comp_result )
	{
		return UN_MATCHED;
	}
	
	comp_result = is_match_fr_bk(dice1, dice2);
	// ?????¢????????¢????????´????????????????¢????
	if( UN_MATCHED == comp_result )
	{
		return UN_MATCHED;
	}
	return MATCHED;
}

/* 2???????§???????????????¢????????¨?????¢??????????????´????????????????????? */
short is_match_top_btm(hexahedron dice1, hexahedron dice2)
{
	if( dice1.top_surf != dice2.top_surf )
	{
		return UN_MATCHED;
	}
	if( dice1.bottom_surf != dice2.bottom_surf )
	{
		return UN_MATCHED;
	}
	return MATCHED;
}

/* 2???????§????????????£??¢????????¨?????¢??????????????´????????????????????? */
short is_match_fr_bk(hexahedron dice1, hexahedron dice2)
{
	if( dice1.front_surf != dice2.front_surf )
	{
		return UN_MATCHED;
	}
	if( dice1.back_surf != dice2.back_surf )
	{
		return UN_MATCHED;
	}
	return MATCHED;
}

/* 2???????§???????????????¢????????¨?????¢??????????????´????????????????????? */
short is_match_r_l(hexahedron dice1, hexahedron dice2)
{
	if( dice1.right_surf != dice2.right_surf )
	{
		return UN_MATCHED;
	}
	if( dice1.left_surf != dice2.left_surf )
	{
		return UN_MATCHED;
	}
	return MATCHED;
}

Measured memory_bytes: 580