ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1380. Ostap's Chess

Time limit: 1.0 second
Memory limit: 64 MB
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 N (1 ≤ N ≤ 109) times, Po had lost the game M (1 ≤ M ≤ 101000) 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 en passant, castling and 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.

Input

The current position is given as 64 numbers, delimited with spaces or new-lines. The number 0 corresponds to an empty square, 1 — to pawn, 2 — to knight, 3 — to bishop, 4 — to rock, 5 — to queen, 6 — to king. The positive numbers correspond to white pieces, and their negative counterparts — to black ones. A number 1 ≤ P ≤ 60 follows, which gives the number of moves written down by Ha. Following is the color of player to move, either 'White' or 'Black'. At last, the P moves are given, formatted as square-square, where a square is a letter a-h (a corresponding to the leftmost file, h to the rightmost) followed by a number 1-8 (1 corresponding to the bottommost rank, 8 to the topmost).

Output

For each move, your program must output either of the following messages: "Incorrect" for illegal move, "Mate" for checkmate, "Check" for check, "Draw" for stalemate, "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.

Samples

inputoutput
-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
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
-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
8
White
e2-e4
e7-e5
d1-f3
h7-h6
f1-c4
g7-g6
f3-f7
e8-f7
Correct
Correct
Correct
Correct
Correct
Correct
Mate

-4 -2 -3 -5 -6 -3 -2 -4
-1 -1 -1 -1 0 5 0 0
0 0 0 0 0 0 -1 -1
0 0 0 0 -1 0 0 0
0 0 3 0 1 0 0 0
0 0 0 0 0 0 0 0
1 1 1 1 0 1 1 1
4 2 3 0 6 0 2 4
0 0 0 0 0 6 0 -6
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 5
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
0 0 0 0 0 0 0 0
1
White
h6-a6
Correct

0 0 0 0 0 6 0 -6
0 0 0 0 0 0 0 0
5 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 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
Problem Author: Ivan Popelyshev
Problem Source: Petrozavodsk summer training camp, August 2005.