#include <bits/stdc++.h>
using namespace std;
const int TAM = 50 + 15;
const long long MOD = 1000000007LL;
const double PI = 3.14159265359;
long long add(long long x, long long y) { return (x + y + 2 * MOD) % MOD; }
long long mult(long long x, long long y) {
  return (add(x, 0) * add(y, 0)) % MOD;
}
long long fast_expo(long long x, long long y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  long long res = 1;
  long long mid = fast_expo(x, y / 2);
  if (y % 2 != 0) res = x;
  return mult(mult(mid, mid), res);
}
long long inver(long long x) { return fast_expo(x, MOD - 2); }
long long gcd(long long e1, long long e2) {
  if (e2 == 0) return e1;
  return gcd(e2, e1 % e2);
}
int b[8][8];
int a[8][8];
int dx[] = {0, 2, 4, 2, 2, 2};
int dy[] = {2, 2, 2, 0, 4, 6};
void mostrar(string s = "") {
  cout << s << endl;
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 8; j++) printf(" %2d", b[i][j]);
    cout << endl;
  }
  cout << endl;
}
void leer(int i, int j) {
  cin >> a[i][j];
  cin >> a[i][j + 1];
  cin >> a[i + 1][j];
  cin >> a[i + 1][j + 1];
}
void copiar() {
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 8; j++) b[i][j] = a[i][j];
  }
}
bool comprobar() {
  for (int i = 0; i < 6; i++) {
    if (b[dx[i]][dy[i]] == b[dx[i] + 1][dy[i]] &&
        b[dx[i]][dy[i]] == b[dx[i]][dy[i] + 1] &&
        b[dx[i]][dy[i]] == b[dx[i] + 1][dy[i] + 1])
      continue;
    return false;
  }
  return true;
}
bool y1() {
  copiar();
  for (int i = 0; i < 8; i++) {
    b[2][i] = a[2][(6 + i) % 8];
  }
  return comprobar();
}
bool y2() {
  copiar();
  for (int i = 0; i < 8; i++) {
    b[2][i] = a[2][(2 + i) % 8];
  }
  return comprobar();
}
bool x1() {
  copiar();
  b[3][6] = a[0][3];
  b[2][6] = a[1][3];
  b[0][3] = a[2][3];
  b[1][3] = a[3][3];
  b[2][3] = a[4][3];
  b[3][3] = a[5][3];
  b[4][3] = a[3][6];
  b[5][3] = a[2][6];
  return comprobar();
}
bool x2() {
  copiar();
  b[3][6] = a[4][3];
  b[2][6] = a[5][3];
  b[0][3] = a[3][6];
  b[1][3] = a[2][6];
  b[2][3] = a[0][3];
  b[3][3] = a[1][3];
  b[4][3] = a[2][3];
  b[5][3] = a[3][3];
  return comprobar();
}
bool z1() {
  copiar();
  b[2][1] = a[1][3];
  b[3][1] = a[1][2];
  b[4][2] = a[2][1];
  b[4][3] = a[3][1];
  b[3][4] = a[4][2];
  b[2][4] = a[4][3];
  b[1][3] = a[3][4];
  b[1][2] = a[2][4];
  return comprobar();
}
bool z2() {
  copiar();
  b[2][1] = a[4][2];
  b[3][1] = a[4][3];
  b[4][2] = a[3][4];
  b[4][3] = a[2][4];
  b[3][4] = a[1][3];
  b[2][4] = a[1][2];
  b[1][3] = a[2][1];
  b[1][2] = a[3][1];
  return comprobar();
}
int main() {
  memset(a, -1, sizeof a);
  for (int i = 0; i < 6; i++) leer(dx[i], dy[i]);
  if (x1() || x2() || y1() || y2() || z1() || z2())
    puts("YES");
  else
    puts("NO");
  return 0;
}

### Prompt

Create a solution in Cpp for the following problem:

During the breaks between competitions, top-model Izabella tries to develop herself and not to be bored. For example, now she tries to solve Rubik's cube 2x2x2.

It's too hard to learn to solve Rubik's cube instantly, so she learns to understand if it's possible to solve the cube in some state using 90-degrees rotation of one face of the cube in any direction.

To check her answers she wants to use a program which will for some state of cube tell if it's possible to solve it using one rotation, described above.

Cube is called solved if for each face of cube all squares on it has the same color.

https://en.wikipedia.org/wiki/Rubik's_Cube

Input

In first line given a sequence of 24 integers ai (1 ≤ ai ≤ 6), where ai denotes color of i-th square. There are exactly 4 occurrences of all colors in this sequence.

Output

Print «YES» (without quotes) if it's possible to solve cube using one rotation and «NO» (without quotes) otherwise.

Examples

Input

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


Output

NO

Input

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


Output

YES

Note

In first test case cube looks like this:

<image>

In second test case cube looks like this: 

<image>

It's possible to solve cube by rotating face with squares with numbers 13, 14, 15, 16.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int TAM = 50 + 15;
const long long MOD = 1000000007LL;
const double PI = 3.14159265359;
long long add(long long x, long long y) { return (x + y + 2 * MOD) % MOD; }
long long mult(long long x, long long y) {
  return (add(x, 0) * add(y, 0)) % MOD;
}
long long fast_expo(long long x, long long y) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  long long res = 1;
  long long mid = fast_expo(x, y / 2);
  if (y % 2 != 0) res = x;
  return mult(mult(mid, mid), res);
}
long long inver(long long x) { return fast_expo(x, MOD - 2); }
long long gcd(long long e1, long long e2) {
  if (e2 == 0) return e1;
  return gcd(e2, e1 % e2);
}
int b[8][8];
int a[8][8];
int dx[] = {0, 2, 4, 2, 2, 2};
int dy[] = {2, 2, 2, 0, 4, 6};
void mostrar(string s = "") {
  cout << s << endl;
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 8; j++) printf(" %2d", b[i][j]);
    cout << endl;
  }
  cout << endl;
}
void leer(int i, int j) {
  cin >> a[i][j];
  cin >> a[i][j + 1];
  cin >> a[i + 1][j];
  cin >> a[i + 1][j + 1];
}
void copiar() {
  for (int i = 0; i < 6; i++) {
    for (int j = 0; j < 8; j++) b[i][j] = a[i][j];
  }
}
bool comprobar() {
  for (int i = 0; i < 6; i++) {
    if (b[dx[i]][dy[i]] == b[dx[i] + 1][dy[i]] &&
        b[dx[i]][dy[i]] == b[dx[i]][dy[i] + 1] &&
        b[dx[i]][dy[i]] == b[dx[i] + 1][dy[i] + 1])
      continue;
    return false;
  }
  return true;
}
bool y1() {
  copiar();
  for (int i = 0; i < 8; i++) {
    b[2][i] = a[2][(6 + i) % 8];
  }
  return comprobar();
}
bool y2() {
  copiar();
  for (int i = 0; i < 8; i++) {
    b[2][i] = a[2][(2 + i) % 8];
  }
  return comprobar();
}
bool x1() {
  copiar();
  b[3][6] = a[0][3];
  b[2][6] = a[1][3];
  b[0][3] = a[2][3];
  b[1][3] = a[3][3];
  b[2][3] = a[4][3];
  b[3][3] = a[5][3];
  b[4][3] = a[3][6];
  b[5][3] = a[2][6];
  return comprobar();
}
bool x2() {
  copiar();
  b[3][6] = a[4][3];
  b[2][6] = a[5][3];
  b[0][3] = a[3][6];
  b[1][3] = a[2][6];
  b[2][3] = a[0][3];
  b[3][3] = a[1][3];
  b[4][3] = a[2][3];
  b[5][3] = a[3][3];
  return comprobar();
}
bool z1() {
  copiar();
  b[2][1] = a[1][3];
  b[3][1] = a[1][2];
  b[4][2] = a[2][1];
  b[4][3] = a[3][1];
  b[3][4] = a[4][2];
  b[2][4] = a[4][3];
  b[1][3] = a[3][4];
  b[1][2] = a[2][4];
  return comprobar();
}
bool z2() {
  copiar();
  b[2][1] = a[4][2];
  b[3][1] = a[4][3];
  b[4][2] = a[3][4];
  b[4][3] = a[2][4];
  b[3][4] = a[1][3];
  b[2][4] = a[1][2];
  b[1][3] = a[2][1];
  b[1][2] = a[3][1];
  return comprobar();
}
int main() {
  memset(a, -1, sizeof a);
  for (int i = 0; i < 6; i++) leer(dx[i], dy[i]);
  if (x1() || x2() || y1() || y2() || z1() || z2())
    puts("YES");
  else
    puts("NO");
  return 0;
}

```