#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int dice(int a, int b){
		int count = 0;
		string tpat[3];
		tpat[0] = "12651";
		tpat[1] = "23542";
		tpat[2] = "13641";
		int ret[3];
		ret[0] = 3;
		ret[1] = 1;
		ret[2] = 5;
		for(int i = 0; i < 3; i++){
				for(int j = 0; j < 4; j++){
						if(tpat[i][j] - '0' == a && tpat[i][j+1] - '0' == b){
								return ret[i];
						}
				}
		}
		tpat[0] = "15621";
		tpat[1] = "24532";
		tpat[2] = "14631";
		for(int i = 0; i < 3; i++){
				for(int j = 0; j < 4; j++){
						if(tpat[i][j] - '0' == a && tpat[i][j+1] - '0' == b){
								return 7 - ret[i];
						}
				}
		}
		return 1;

}

int main(int argc, char const* argv[])
{
	int d[6];
	for(int i = 0; i < 6; i++){
			cin >> d[i];
	}
	int e[6];
	for(int i = 0; i < 6; i++){
			cin >> e[i];
	}
	int a1 = 0;
	int a2 = 1;
	while(d[a1] == d[a2] && a2 < 7)a2++;
	int b1[6];
	int b2[6];
	int c1 = 0;
	int c2 = 0;
	for(int i = 0; i < 6; i++){
			if(d[a1] == e[i])b1[c1++] = i;
			if(d[a2] == e[i])b2[c2++] = i;
	}
	for(int i = 0; i < c1; i++){
			for(int j = 0; j < c2; j++){
					if(d[dice(a1+1, a2+1)-1] == e[dice(b1[i]+1, b2[j]+1)-1] && d[5-a1] == e[5-b1[i]] && d[5-a2] == e[5-b2[j]]){
						cout << "Yes" << endl;
						return 0;
					}
			}
	}
	cout << "No" << endl;
	return 0;
}


### Prompt

Develop a solution in CPP to the problem described below:

Write a program which reads the two dices constructed in the same way as Dice I, and determines whether these two dices are identical. You can roll a dice in the same way as Dice I, and if all integers observed from the six directions are the same as that of another dice, these dices can be considered as identical.

Constraints

* $0 \leq $ the integer assigned to a face $ \leq 100$

Input

In the first line, six integers assigned to faces of a dice are given in ascending order of their corresponding labels.
In the second line, six integers assigned to faces of another dice are given in ascending order of their corresponding labels.

Output

Print "Yes" if two dices are identical, otherwise "No" in a line.

Examples

Input

1 2 3 4 5 6
6 2 4 3 5 1


Output

Yes


Input

1 2 3 4 5 6
6 5 4 3 2 1


Output

No

### Response

```cpp
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int dice(int a, int b){
		int count = 0;
		string tpat[3];
		tpat[0] = "12651";
		tpat[1] = "23542";
		tpat[2] = "13641";
		int ret[3];
		ret[0] = 3;
		ret[1] = 1;
		ret[2] = 5;
		for(int i = 0; i < 3; i++){
				for(int j = 0; j < 4; j++){
						if(tpat[i][j] - '0' == a && tpat[i][j+1] - '0' == b){
								return ret[i];
						}
				}
		}
		tpat[0] = "15621";
		tpat[1] = "24532";
		tpat[2] = "14631";
		for(int i = 0; i < 3; i++){
				for(int j = 0; j < 4; j++){
						if(tpat[i][j] - '0' == a && tpat[i][j+1] - '0' == b){
								return 7 - ret[i];
						}
				}
		}
		return 1;

}

int main(int argc, char const* argv[])
{
	int d[6];
	for(int i = 0; i < 6; i++){
			cin >> d[i];
	}
	int e[6];
	for(int i = 0; i < 6; i++){
			cin >> e[i];
	}
	int a1 = 0;
	int a2 = 1;
	while(d[a1] == d[a2] && a2 < 7)a2++;
	int b1[6];
	int b2[6];
	int c1 = 0;
	int c2 = 0;
	for(int i = 0; i < 6; i++){
			if(d[a1] == e[i])b1[c1++] = i;
			if(d[a2] == e[i])b2[c2++] = i;
	}
	for(int i = 0; i < c1; i++){
			for(int j = 0; j < c2; j++){
					if(d[dice(a1+1, a2+1)-1] == e[dice(b1[i]+1, b2[j]+1)-1] && d[5-a1] == e[5-b1[i]] && d[5-a2] == e[5-b2[j]]){
						cout << "Yes" << endl;
						return 0;
					}
			}
	}
	cout << "No" << endl;
	return 0;
}


```