Make a Sequence#3196

Make a Sequence

5 seconds
64 megabytes
Medium

Your company's next product is a new game, which is a three-dimensional version of the classic game "Tic-Tac-Toe." Two players place balls into a three-dimensional space (board) and try to make a sequence of a certain length.

People believe the game is fun, but have not yet fixed the values of some parameters. For example, what board size makes the game most exciting? The currently discussed parameters are the board size (denoted as ) and the length of the sequence (). To determine these values, you are requested to write a computer simulator of the game.

Several snapshots of the game can be seen in Figures 1–3, corresponding to the three datasets given in the Sample Input.

Figure 1. A game with n=m=3

Figure 2. A game with n=m=3 (White made a 3-sequence before Black)

Figure 3. A game with n=4, m=3 (Black made two 4-sequences)

Here are the precise rules of the game.

  1. Two players, Black and White, play alternately. Black plays first.

  2. There are vertical pegs. Each peg can hold at most balls. A peg is specified by its - and -coordinates (1 \le x, y \le n). A ball on a peg is specified by its -coordinate (1 \le z \le n). At the start of the game, all pegs are empty.

  3. On their turn, a player selects one of the pegs and puts a ball of their color onto the peg. The ball follows the law of gravity: it stays just above the topmost ball on that peg or on the floor (if the peg is empty). In other words, a player can choose the - and -coordinates, but not the -coordinate.

  4. The objective is to create an -sequence. If a player makes an -sequence or longer in their color, they win. An -sequence consists of consecutive balls of the same color. For example, black balls at (5, 1, 2), (5, 2, 2), and (5, 3, 2) form a 3-sequence. A sequence may be horizontal, vertical, or diagonal. There are possible directions, categorized as follows:

    1. One-dimensional axes. For example, (3, 1, 2), (4, 1, 2), and (5, 1, 2) form a 3-sequence. There are three directions in this category.

    2. Two-dimensional diagonals. For example, (2, 3, 1), (3, 3, 2), and (4, 3, 3) form a 3-sequence. There are six directions in this category.

    3. Three-dimensional diagonals. For example, (5, 1, 3), (4, 2, 4), and (3, 3, 5) form a 3-sequence. There are four directions in this category.

Note that opposite directions are not distinguished.

As part of the evaluation, people played the game multiple times with varying parameter values. The records of these games are given. Your task is to write a computer program to determine the winner of each recorded game.

Since it is difficult for a human to notice 3D sequences, players may fail to notice the end and continue playing after the game is decided. In these cases, any moves made after the outcome is determined must be ignored. For example, if a player wins by making an -sequence, further -sequences made later are ignored, and the winner does not change.

A game does not necessarily end with a winner. If no further balls can be placed on any peg, the game ends in a draw. Also, if players quit without any -sequence, the game is a draw.

Input

The input consists of several datasets, each corresponding to the record of a game.

A dataset starts with a line containing three positive integers , , and separated by a space. The constraints 3 \le m \le n \le 7 and 1 \le p \le n^3 hold. and are as described above; is the number of moves in the game.

The following lines each contain two positive integers and . Each line describes a move: the player on turn places their ball on the peg at . It is guaranteed that 1 \le x \le n and 1 \le y \le n and that no peg receives more than balls during the game.

The end of input is indicated by a line containing three zeros.

Output

For each dataset, output a line describing the winner and the count of moves until the end. The winner is either **Black** or **White**. Insert a single space between the winner and the number of moves. No other extra characters are allowed.

In case of a draw, output line should be **Draw**.

Examples

Example 1

Loading
Loading