F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Problem G

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1    Accepted Submission(s): 1


Problem Description
Gomoku is an abstract strategy board game. Named Gobang or Five in a Row as well, it is traditionally played with pieces of two colors (black and white) on a board (with $N \times M$ intersections). Once a piece is placed, it is not allowed to be moved or removed from the chessboard.

The rules of the game are quite simple. The black plays first, and two players alternate in placing a stone of their own color on an empty intersection. The winner is the first one who gets an unbroken row of five stones of his/her color horizontally, vertically, or diagonally.

Now we have already drawn some stages of the game, and you're required to answer, that for each stage whether it is possible to reach, and if so, who has already won the game. You have to solve it as soon as possible, because there are no much time left in the competition now!
 

Input
The number of test cases $T (T \leq 150)$ will occur in the first line of input.

For each test case:

The first line contains the size of the board $N$ and $M (1 \leq N, M \leq
100)$.

Then $N$ lines followed, each with exactly $M$ characters. The white stone is denoted by '1', and the black stone is denoted by '2', while the empty intersections are denoted by '.' (a full period).
 

Output
For each test case, if it is impossible to arrive at such a stage, output “fault”. Otherwise, if the white piece wins, then output “white”; if the black piece wins, output “black”; or else output “other”.
 

Sample Input
2 10 10 .......... .......... ...1...... ...2...... .......... .......... .......... .......... .......... .......... 10 10 .......... .......... .......... ...1...... ..1....... ..1.2..... .......... .......... .......... ..........
 

Sample Output
other fault
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2025 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2025-03-29 20:32:47, Gzip enabled