Crazy Bishops
When studying chess, many people are first taught how to checkmate the lone king. In this problem you have to check whether it is possible to checkmate the lone black king with two bishops and a king, starting from a given position.
Recall that a king can move one cell in each of the eight directions, a bishop can move any number of cells in diagonal direction. A king cannot move to the cell that is attacked by some piece. A bishop can move to any cell, but he must not move to the cell that is attacked by the black king, if it is not protected, in other case it can be taken by the black king and the game ends in draw.
Given the position on the board and the side that has the turn, you have to detect whether white can win, or black can force the game to end in draw.
Remember, that if the black king has no possible moves, but is not checkmated (i.e. it is stalemated), the game is considered to end in draw.
Input
The first line of the input file contains cells where white king and two bishops are located, respectively. The second line contains the cell where the black king is located. Standard chess notation is used, letters 'a' to 'h' stand for verticals and digits '1' to '8' for horizontals.
The last line contains "white" if it’s white’s turn and "black" if it’s black’s turn.
The position is guaranteed to be valid, i.e. no king can be taken on the current turn.
Output
Output "white wins" if white can win, and "draw" if it cannot.