Yash plays with CUBE

3.4

15 votes
Problem

One day, Yash found a cube which has each of its sides painted in some color out of white, blue, red, green, yellow and purple. Now he asks you to check if he can choose three sides such that they are pairwise adjacent and painted in the same color.

INPUT: A single line of each test case contains six words denoting the colors of painted sides in the order: front, back, left, right, top and bottom, respectively.(Separated by " "(space) eg: blue yellow green orange white green, blue is in front ,yellow in back and so on)

OUTPUT:

For each test case, output a single line containing the word "YES" or "NO" (without quotes) corresponding to the answer of the problem.

SAMPLE INPUT 1: blue yellow green orange white green

SAMPLE OUTPUT 1 : NO

SAMPLE INPUT 2: green yellow green purple white green

SAMPLE OUTPUT 2 : YES

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?