Influence is a board game. It can be played on almost any layout, but an interesting one is a hexagonal $N \times N$ grid shaped like a rhombus.
An example 9×9 board looks like this:
1 2 3 4 5 6 7 8 9
\ \ \ \ \ \ \ \ \
* * * * * * * * * — A
* * * * * * * * * — B
* * * * * * * * * — C
* * * * * * * * * — D
* * * * * * * * * — E
* * * * * * * * * — F
* * * * * * * * * — G
* * * * * * * * * — H
* * * * * * * * * — I
Rows are labeled A through I from top to bottom, and columns are labeled 1 through 9. On this grid, cell F5 is adjacent to F4, F6, E5, E6, G4, and G5. (These coordinate labels only explain the adjacencies; they never appear in the input.)
The relevant rules of Influence are:
The player with the most Influence at the end of the game wins. For instance, with three players one arrangement gives the first player (!) 2 Influence, the second player (@) 10 Influence, and the third player (#) 4 Influence, while 9 tied locations count for no one.
For each player, report the maximum Influence that player could hold after a single optimal last move: placing one additional Manipulator on the best empty location, or passing if the board is full. Every player's best move is evaluated independently on the original board, never on a board already changed by another player's move.
The first line contains an integer $N$ ($1 \le N \le 100$), the number of data sets. Each data set consists of:
. — an empty location;! — a Manipulator of the first player;@ — a Manipulator of the second player;# — a Manipulator of the third player (only when $P \ge 3$);$ — a Manipulator of the fourth player (only when $P \ge 4$).The board lines may contain extra leading spaces so the input resembles the slanted layout above; this extra whitespace is not significant.
For each data set, print a line DATA SET #K, where $K$ is 1 for the first data set, 2 for the second, and so on. Then print $P$ lines: the maximum Influence achievable by the first, second, third (when playing), and fourth (when playing) player, in that order, each from a single optimal last move computed on the original board.