Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ACM-ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

No tag edit access

C. Solution for Cube

time limit per test

2 secondsmemory limit per test

256 megabytesinput

standard inputoutput

standard outputDuring 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.

Input

In first line given a sequence of 24 integers *a*_{i} (1 ≤ *a*_{i} ≤ 6), where *a*_{i} 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:

In second test case cube looks like this:

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

Codeforces (c) Copyright 2010-2018 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Feb/25/2018 12:27:49 (d1).

Desktop version, switch to mobile version.

User lists

Name |
---|