eolymp
bolt
Try our new interface for solving problems
Problems

Ostap`s Chess

Ostap`s Chess

The well-known grand-master Bender arrives at the city of Petrozavodsk. Among others, there were Ha, Ru and Po to come to the simultaneous chess-game. Ru had lost the game \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{10^9}) times, Po had lost the game \textbf{M} (\textbf{1} ≤ \textbf{M} ≤ \textbf{10^1000}) times, and Ha hadn't counted his losses as all. The friends had noticed that Bender played in his own style: the chess-pieces occasionally disappeared from the board, or new pieces occasionally appeared. Bender has no shame, and he can do the cheats with any chess-piece. Then Ha got tired of these games, and he decided to start writing down the moves, having written down the current position first. You have to tell from Ha's notes whether Ostap cheated during play, or not. The rules of chess, as known by Ostap, are much like the common ones, but Ostap doesn't know such concepts as \textit{en passant}, \textit{castling} and \textit{promotion}. Otherwise, the pieces move just like the usual chess-pieces do. A player's move is considered legal if the only piece moved is this player's piece, and his king isn't in check at the end of the move. A king is considered in check when its location is under attack of a hostile piece, and checkmated when, in addition to this, there is no legal moves. Stalemate (a draw) is a position when neither king is in check, and there is no legal moves. The initial position may be senseless; it needn't be verified before the first move. \InputFile The current position is given as \textbf{64} numbers, delimited with spaces or new-lines. The number \textbf{0} corresponds to an empty square, \textbf{1} --- to pawn, \textbf{2} --- to knight, \textbf{3} --- to bishop, \textbf{4} --- to rock, \textbf{5} --- to queen, \textbf{6} --- to king. The positive numbers correspond to white pieces, and their negative counterparts --- to black ones. A number \textbf{1} ≤ \textbf{P} ≤ \textbf{60} --- follows, which gives the number of moves written down by Ha. Following is the color of player to move, either \textbf{White} or \textbf{Black}. At last, the \textbf{P} moves are given, formatted as square-square, where a square is a letter \textbf{a}-\textbf{h} (\textbf{a} corresponding to the leftmost file, \textbf{h} to the rightmost) followed by a number \textbf{1}-\textbf{8} (\textbf{1} corresponding to the bottommost rank, \textbf{8} to the topmost). \OutputFile For each move, your program must output either of the following messages: "\textbf{Incorrect}" --- for illegal move,"\textbf{Mate}" --- for checkmate, "\textbf{Check}" --- for check, "\textbf{Draw}" --- for stalemate, "\textbf{Correct}" --- for neither of the above. After an illegal move, checkmate or stalemate, the program must output an empty line followed by the current position, formatted in the same way as the input, without performing the illegal move. The moves following the illegal move, checkmate or stalemate must be ignored.
Time limit 1 second
Memory limit 64 MiB
Input example #1
-4 -2 -3 -5 -6 -3 -2 -4 
-1 -1 -1 -1 -1 -1 -1 -1 
0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 
0 0 0 0 0 0 0 0 
1 1 1 1 1 1 1 1 
4 2 3 5 6 3 2 4 
2
White
e2-e4
e7-e4
Output example #1
Correct
Incorrect

-4 -2 -3 -5 -6 -3 -2 -4
-1 -1 -1 -1 -1 -1 -1 -1
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0
1 1 1 1 0 1 1 1
4 2 3 5 6 3 2 4
Author Andrew Rumyantsev
Source Petrozavodsk summer training camp, August 2005.