Codeforces Global Round 1
G
Tree-Tac-Toe
Codeforces
3100
原题
← FH →
翻译中…

The tic-tac-toe game is starting on a tree of $n$ vertices. Some vertices are already colored in white while the remaining are uncolored.

翻译中…

There are two players — white and black. The players make moves alternatively. The white player starts the game. In his turn, a player must select one uncolored vertex and paint it in his color.

翻译中…

The player wins if he paints some path of three vertices in his color. In case all vertices are colored and neither player won, the game ends in a draw.

翻译中…

Could you please find who will win the game or whether it ends as a draw, assuming both players play optimally?

翻译中…

Input

翻译中…

The first line contains a single integer $T$ ($1 \le T \le 50\,000$) — the number of test cases. Then descriptions of $T$ test cases follow.

翻译中…

The first line of each test contains a single integer $n$ ($1 \le n \le 5 \cdot 10^5$) — the number of vertices in the tree.

翻译中…

Each of the following $n - 1$ lines contains integers $v$, $u$ ($1 \le v, u \le n$) denoting an edge of the tree connecting vertices $v$ and $u$.

翻译中…

The last line of a test case contains a string of letters 'W' (for white) and 'N' (for not colored) of length $n$ denoting already colored vertices. Vertexes already colored in white are denoted as 'W'.

翻译中…

It's guaranteed that the given edges form a tree, that there is at least one uncolored vertex and that there is no path of three white vertices.

翻译中…

It's guaranteed that sum of all $n$ among all test cases is at most $5 \cdot 10^5$.

翻译中…

Output

翻译中…

For every test case, print either "White", "Draw" or "Black", depending on the result of the game.

翻译中…

Note

翻译中…

In the first example, vertex $4$ is already colored in white. The white player can win by coloring the vertex $1$ in white first and the remaining vertex on his second turn. The process is illustrated with the pictures below.

翻译中…

image

翻译中…

In the second example, we can show that no player can enforce their victory.

翻译中…

样例

Input #1
2
4
1 2
1 3
1 4
NNNW
5
1 2
2 3
3 4
4 5
NNNNN
Output #1
White
Draw
InputCopy OutputCopy
题目信息
题号
1110G
时间限制
3 s
内存限制
256 MB
标签
构造
博弈论
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。