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

1216. Two Pawns and One King

Time limit: 1.0 second
Memory limit: 64 MB
Somewhere on the N × N chessboard, there are one white pawn, one black pawn, and the black King as well. A game is being played according to the usual chess rules* (except the absence of the white King). White is supposed to win, when it manages to promote its pawn to the Queen (even in the case when this queen would be immediately beaten by the next black’s move). Otherwise, Black is considered to be the winner (even if in some position White has no possibilities to move its pawn). Given an initial position, your program is to determine the winner.
* Usual chess rules mean exactly the following:
  • White moves first.
  • In the initial position, pawns are not on the first or the N-th horizontal row.
  • White pawn is allowed to move to the fourth horizontal from the second, and black pawn is allowed to move to the (N−3)-rd horizontal row from the (N−1)-st. Pawns can't jump over other pieces.
  • Just after the white pawn makes a move from x2 to x4, the black pawn may beat the white pawn en passant, moving from y4 to x3, if y is a vertical line, neighboring to the x-vertical.
  • In all other cases, pawns move one field along the vertical and beat one field along the diagonal. King moves one field in any direction.
  • If it is not Black’s turn to move, the black King should not be under check, i.e. in the position, when the white pawn could beat it.
  • When a black pawn reaches the first horizontal, it should be promoted to the Queen, Rook, Knight or Bishop, according to the wish of the Black player. (But when a white pawn reaches the N-th horizontal, it should be promoted to the Queen and our game immediately finishes).

Input

The first line contains a single integer N, 6 ≤ N ≤ 26. In the second line, the positions of the white pawn, black pawn and black King (in this very order!) are given, separated by one or several white spaces. A description of a position consists of a small Latin letter, which denotes the vertical, and (without a space) an integer number (from 1 to N) denoting the horizontal.

Output

Output a message "WHITE WINS", when White can win the game according to the above described rules, and "BLACK WINS" otherwise.

Samples

inputoutput
10
h5 i5 b3
WHITE WINS
8
d5 h6 b6
BLACK WINS
Problem Author: Leonid Volkov
Problem Source: The Seventh Ural State University collegiate programming contest