Time Limit: 2 sec
Memory Limit: 32 MB
Everybody knows how to play tic-tac-toe. If accidentally you do not know the rules of this game, you can always consult Wikipedia.
In this problem we will use a slightly different version of tic-tac-toe. First, the game board is not limited to 3x3 cells, but considered infinite. Also in order to win a player must get not 3 but at least k noughts or crosses in a line (horizontal, vertical or diagonal).
In modified tic-tac-to version it is not so easy to determine a winner. So in this problem you will be given a list of turns performed by the players during the game and you need to determine the winner.
There is a number of tests T
(T ≤ 100) on the first line. Each test case is described by the two numbers n k
(n ≤ 105, k ≤ 5), where n
stands for number of turns for both players and k
for winning line size. Next line contains n
pairs of signed 32-bit integers x y
— coordinates of each players turn. All turns have been performed sequentially by both players and crosses have always started a game.
For each test case output a single line "Case T: S"
. Where T
is the test case number (starting from 1) and S
is equal to "crosses"
or "noughts"
if one of them has a winning line. If nobody yet has won a game output "none"
and if both players have winning lines output "error"
for "S"
.
2 3 2 0 0 1 1 1 0 4 2 0 0 -1 0 1 1 -1 1
Case 1: crosses Case 2: error