408287: GYM103076 J Impress your friends

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Impress your friendstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You and your group of friends went to the Café at Area II to have a coffee between classes. As usual the group makes a circle and starts to chat and you want to seize this opportunity to impress your friends! However, the risk of you being embarrassed must be taken into account. In order to do this, you need to know in a timely manner if it is possible to solve a 2x2x2 magic cube within 5 moves, since more than this would make you look like a goofy.

A 2x2x2 cube can be flattened by cutting its edges. The result would look like this:

Input

You'll receive 8 line where each one of them represents a line of the cube printed into a 2D plan.

..NO..

..MP..

..JK..

..IL..

BCFGVW

ADEHUZ

..RS..

..QT..

Replace every letter with a digit between 1 and 6, representing the color. It's guaranteed that each colors appears exactly 4 times.

Output

For the single test case:

"YES", if you can impress your friends; "NO", otherwise.

You may print every letter in any case you want (so, for example, the strings yEs, yes, Yes and YES are all recognized as positive answer).

ExamplesInput
..13..
..25..
..46..
..66..
145253
342251
..13..
..46..
Output
NO
Input
..33..
..55..
..66..
..66..
112233
551122
..44..
..44..
Output
YES

加入题单

上一题 下一题 算法标签: