4x4 tic-tac-toe is played on a board with four rows (numbered 0 to 3 from top to bottom) and four columns (numbered 0 to 3 from left to right). Two players, x and o, move alternately, and x always moves first. A player wins by being the first to place four of their pieces on the same row, the same column, or a main diagonal. If the board fills up and neither player has four in a line, the game is a draw.
It is x's turn to move. We say that x has a forced win if x can make a move such that, no matter how o responds for the rest of the game, x is guaranteed to win eventually. This does not necessarily mean x will win on the very next move (although that is possible); it means x has a strategy that guarantees an eventual victory regardless of what o does.
Given a partially played game with x to move next, determine whether x has a forced win. You may assume that each player has already made at least two moves, that neither player has won yet, and that the board is not full.
The input contains one or more test cases, followed by a line that begins with a $ character to signal the end of the input. Each test case begins with a line containing a single ?, followed by four lines describing the board. Each board line has exactly four characters: a period . for an empty cell, a lowercase x, or a lowercase o.
For each test case, output one line. If x has a forced win, print the (row,column) position of the first such winning move, formatted exactly as (row,column) with no spaces (for example (0,1)). If x has no forced win, print ##### instead.
The first forced win is determined by board position, not by the number of moves required to win. Examine the cells in the order (0,0), (0,1), (0,2), (0,3), (1,0), (1,1), ..., (3,2), (3,3), and output the first forced win you find. For example, in the second sample board (o... / .ox. / .xxx / xooo), x could win immediately by playing at (0,3) or (2,0), but playing at (0,1) still guarantees victory (it merely delays it), and (0,1) comes earlier in the search order, so (0,1) is the answer.