Codeforces Round 444 (Div. 2)
C
Solution for Cube
Codeforces
1500
原题
← BD →
翻译中…

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.

翻译中…

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.

翻译中…

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.

翻译中…

样例

Input #1
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 #1
NO
InputCopy OutputCopy
Input #2
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 #2
YES
InputCopy OutputCopy
题目信息
题号
887C
时间限制
2 s
内存限制
256 MB
标签
暴力
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。