Tic Tac Toe

Read a 3x3 board of X, O, and dots and print YES if some row, column, or diagonal has three equal non-dot symbols.

Easy2ImplementationMatrixBrute forceInterviewNo attempts yetTime limit2sMemory limit512 MB

Problem

Write a program that checks the result of one tic tac toe game. The board is a 3x3 grid, and each cell is empty or holds an X or an O. A player wins when three equal symbols stand in one row, in one column, or on one diagonal, and the game then ends with a winner. The three boards below are finished with a winner. Empty cells are written as dots.

X.X     OX.    .X.
OOO     .O.    .X.
...     X.O    .XO

The next three boards have no winner.

OXO    X..    ...
XXO    O.O    .X.
OOX    .XX    ..O

Three dots in a line do not count as a win.

Input

The input has three lines. Each line has three characters, and each character is a dot, an O, or an X. The symbol is the letter O, not the digit zero.

Output

Print YES on one line if the board has a winner, or NO if it does not.