#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>

//#define __DEBUG__

class Dice {

	private:
		int iNS[4];
		int iEW[4];

	public:
		Dice( int v1, int v2, int v3, int v4, int v5, int v6 ) {
			iNS[0] = v1;
			iNS[1] = v2;
			iNS[2] = v6;
			iNS[3] = v5;

			iEW[0] = v1;
			iEW[1] = v3;
			iEW[2] = v6;
			iEW[3] = v4;

#ifdef __DEBUG__
			printf("NS[%d %d %d %d]\n", iNS[0], iNS[1], iNS[2], iNS[3]);
			printf("EW[%d %d %d %d]\n", iEW[0], iEW[1], iEW[2], iEW[3]);
#endif
		}

		void rotateN() {
			int iTmp = iNS[0];
			iNS[0] = iNS[1];
			iNS[1] = iNS[2];
			iNS[2] = iNS[3];
			iNS[3] = iTmp;

			iEW[0] = iNS[0];
			iEW[2] = iNS[2];

#ifdef __DEBUG__
			printf("RotateN ");
			printf("NS[%d %d %d %d] ", iNS[0], iNS[1], iNS[2], iNS[3]);
			printf("EW[%d %d %d %d]\n", iEW[0], iEW[1], iEW[2], iEW[3]);
#endif
		}

		void rotateS() {
			int iTmp = iNS[0];
			iNS[0] = iNS[3];
			iNS[3] = iNS[2];
			iNS[2] = iNS[1];
			iNS[1] = iTmp;

			iEW[0] = iNS[0];
			iEW[2] = iNS[2];

#ifdef __DEBUG__
			printf("RotateS ");
			printf("NS[%d %d %d %d] ", iNS[0], iNS[1], iNS[2], iNS[3]);
			printf("EW[%d %d %d %d]\n", iEW[0], iEW[1], iEW[2], iEW[3]);
#endif
		}

		void rotateE() {
			int iTmp = iEW[0];
			iEW[0] = iEW[3];
			iEW[3] = iEW[2];
			iEW[2] = iEW[1];
			iEW[1] = iTmp;

			iNS[0] = iEW[0];
			iNS[2] = iEW[2];

#ifdef __DEBUG__
			printf("RotateE ");
			printf("NS[%d %d %d %d] ", iNS[0], iNS[1], iNS[2], iNS[3]);
			printf("EW[%d %d %d %d]\n", iEW[0], iEW[1], iEW[2], iEW[3]);
#endif

		}

		void rotateW() {
			int iTmp = iEW[0];
			iEW[0] = iEW[1];
			iEW[1] = iEW[2];
			iEW[2] = iEW[3];
			iEW[3] = iTmp;

			iNS[0] = iEW[0];
			iNS[2] = iEW[2];

#ifdef __DEBUG__
			printf("RotateW ");
			printf("NS[%d %d %d %d] ", iNS[0], iNS[1], iNS[2], iNS[3]);
			printf("EW[%d %d %d %d]\n", iEW[0], iEW[1], iEW[2], iEW[3]);
#endif
		}

		void setDice(int v1, int v2, int v3, int v4, int v5, int v6) {
			iNS[0] = v1;
			iNS[1] = v2;
			iNS[2] = v6;
			iNS[3] = v5;

			iEW[0] = v1;
			iEW[1] = v3;
			iEW[2] = v6;
			iEW[3] = v4;
		}

		int getTop() {
			return iNS[0];
		}
		int getBottom() {
			return iNS[2];
		}
		int getFront() {
			return iNS[1];
		}
		int getBack() {
			return iNS[3];
		}
		int getRight() {
			return iEW[1];
		}
		int getLeft() {
			return iEW[3];
		}

		bool compareDice(Dice *dest) {
			if (iNS[0] == dest->getTop() && iNS[1] == dest->getFront() &&
				iNS[2] == dest->getBottom() && iNS[3] == dest->getBack() &&
				iEW[1] == dest->getRight() && iEW[3] == dest->getLeft() ) {
				return true;
			}
			return false;
		}

};

int main(void) {


	int v1, v2, v3, v4, v5, v6;
	int v7, v8, v9, v10, v11, v12;

	v1 = v2 = v3 = v4 = v5 = v6 = 0;
	v7 = v8 = v9 = v10 = v11 = v12 = 0;

	// dice definition
	scanf("%d %d %d %d %d %d", &v1, &v2, &v3, &v4, &v5, &v6 );
	Dice *d1 = new Dice(v1, v2, v3, v4, v5, v6);
	scanf("%d %d %d %d %d %d", &v7, &v8, &v9, &v10, &v11, &v12);
	Dice *d2 = new Dice(v7, v8, v9, v10, v11, v12);

	bool bFound = false;
	int depth = 0;
	for ( int i = 0; i < 4; i++ ) {
		if (d2->getFront() == d1->getFront()) {	// front value match
			for ( int j = 0; j < 4; j++ ) {
				if (d1->compareDice(d2) == true) {
					printf("Yes\n");
					return 0;
				}
				d2->rotateE();
			}
		}
		if (d1->compareDice(d2) == true) {
			printf("Yes\n");
			return 0;
		}
		d2->rotateN();
	}
	if (d1->compareDice(d2) == true) {
		printf("Yes\n");
		return 0;
	}
	d2->setDice(v7, v8, v9, v10, v11, v12);
	d2->rotateE();
	for (int i = 0; i < 4; i++) {
		if (d2->getFront() == d1->getFront()) {	// front value match
			for (int j = 0; j < 4; j++) {
				if (d1->compareDice(d2) == true) {
					printf("Yes\n");
					return 0;
				}
				d2->rotateE();
			}
		}
		if (d1->compareDice(d2) == true) {
			printf("Yes\n");
			return 0;
		}
		d2->rotateN();
	}
	if (d1->compareDice(d2) == true) {
		printf("Yes\n");
		return 0;
	}
	printf("No\n");
	return 0;

}

Measured memory_bytes: 2672