KNGCHECK - Check

Chess is a two-player strategy board game played on a chessboard, a square checkered game board with 64 squares arranged in an eight-by-eight grid. It is one of the world's most popular games, played by millions of people worldwide at home, in clubs, online, by correspondence, and in tournaments. Each player begins the game with 16 pieces: one king, one queen, two rooks, two knights, two bishops, and eight pawns. Each of the six piece types moves differently. Pieces are used to attack and capture the opponent's pieces, with the objective to 'checkmate' the opponent's king by placing it under an inescapable threat of capture. In addition to checkmate, the game can be won by the voluntary resignation of the opponent, which typically occurs when too much material is lost, or if checkmate appears unavoidable. A game may also result in a draw in several ways, where neither player wins. The course of the game is divided into three phases: opening, middle game, and endgame. Source Wikipedia

To simplify this problem you will only deal with kings, knights and pawns of the black and the white players. Assume that the white player starts at the lower half of the board and the black player starts at the upper half. Given the state of the board, your task is to determine whether the black king is checked or not. For clarity a 'Check' occurs when the King's square can be attacked by any of the opponent's pieces for his next move, and note that in this problem we will ignore the consequences which will follow, we don’t even care whose turn is now but only consider the board state (out of chess rules).

The knight moves like an "L", it moves from cell (r1, c1) to cell (r2, c2) if and only if (r1 - r2)2 + (c1-c2)2 = 5 (8 possible moves).

The king can move only one move in its four main directions and its four diagonals (8 possible moves).

The pawn attacks only one move diagonally and only to the opponent direction (2 possible moves).

This problem is NOT following all chess rules, for example in real chess third case in the sample is INVALID, so please assume that the given board is always valid, just check the black king state.

Input

You are given an 8x8 board with chess pieces denoted as following: BK = black king, WK = white king, BH = black knight, WH = white knight, BP = black pawn, WP = white pawn. We ensure that there is one and only one black king in the chess board. Blank fields are denoted by “-”. Cases are separated by blank lines.

Output

You should output “Check” if a check exists or “Not Check” if no check exists. Follow the output format described in the sample tests.

Example

Input:
3
- - - - - - - -
- - - - - - - -
- - - - - - - -
- BH - - - - - -
- - - BK - - - -
- - WP - - - - -
- - - - - - - -
- - - - - - - -

- - - - - - - -
BH - - BH - - - -
- - - - - - - -
- - - - - - - -
- - - BK - - - -
- - - - - - - -
- WP - - - - WH -
- - - WK - - - -

- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - -
- - - BK - - - -
- - - WK - - - -
- - - - - - WH -
- - - - - - - -

Output:
Case #1: Check
Case #2: Not Check
Case #3: Check

Added by:Sharaf
Date:2013-02-07
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:2013 acmASCIS Level 1 Contest

hide comments
2017-10-15 09:53:06 Simes
@Vipul Srivastava - see CSTATE1, CSTATE2 and CSTATE3
2017-01-18 05:18:24 Vipul Srivastava
How about a question of the same sort with a difference that instead of check condition, you have to check for the checkmate condition. That is, no matter where the black king moves it is faced by some white piece attacking it.

Last edit: 2017-01-18 06:21:00
2014-05-18 13:56:02 Cosmos
consider test cases when there is no white king on the board. gave me a lot of WAs.
2013-06-11 13:59:43 Aman Kumar Sinha
There is a new line character after each test case.Caused me few WAs.
2013-06-02 13:17:41 Atul Kumar Verma
one new line character caused me many WA..in such an easy problem.
2013-03-07 07:15:27 david_8k
Pure violation.
2013-02-17 11:37:43 Aditya Pande
Ac made a silly mistake on the first try

ya problemsetter try to make the problem harder. All possible forms of check should be considered at the very least. Knight and pawn are the easier cases...:p


Last edit: 2013-02-20 09:02:10
2013-02-16 03:54:21 (Tjandra Satria Gunawan)(曾毅昆)
easy problem...
2013-02-14 12:50:41 STARK
how many maximum white pawns and white knights can be there ??? 8 and 2 ?? or it is voilating chess rules in this case too ??
2013-02-13 20:40:39 abdou_93
Please Check MY Code.....
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.