887_C. Solution for Cube_33211
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.
#include <bits/stdc++.h>
using namespace std;
int const N = 1 << 18;
int const M = 1 << 18;
int main(int argc, char* argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int color[30];
  for (int i = 0; i < 24; ++i) cin >> color[i];
  const char* ans[12] = {
      "111155223333224466554466", "111144223333664422555566",
      "114422225533434315156666", "115522224433414135356666",
      "111122553333442255666644", "111122443333446655226655",
      "212132326363444455556161", "616112122323444455556363",
      "121223233636444455551616", "161621213232444455553636",
      "551122223344141453536666", "441122223355343451516666"};
  for (int k = 0; k < 12; ++k) {
    const char* s = ans[k];
    bool ok = true;
    for (int i = 0; i < 24; ++i) {
      for (int j = 0; j < 24; ++j) {
        bool a = color[i] == color[j];
        bool b = s[i] == s[j];
        if (a ^ b) {
          ok = false;
        }
      }
    }
    if (ok) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}
