K. Keen Eye
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

This is an interactive problem.

Bob wanted to communicate an $$$n$$$-digit code to Alice (each character is from 0123456789 and the code may have leading zeros). Alice forgot her contact lenses today, so her eyesight is a bit bad. To help make it easier for her to see, Bob blew up this code into ASCII art and printed it out on a gigantic billboard.

Each digit can be encoded using a grid with $$$8$$$ rows and $$$5$$$ columns. Here are the designs that Bob used for this project:

In Bob's ASCII art, black pixels are represented with the # character, while white pixels are represented with the . character. Also, for clarity, Bob put a column of . characters between each digit's representation in the grid. So, for example, 069 would be encoded like this:


.###...###...###.
#...#.#.....#...#
#..##.#.....#...#
#.#.#.####..#...#
##..#.#...#..####
#...#.#...#.....#
#...#.#...#.#...#
.###...###...###.
In general, Bob's art has $$$8$$$ rows and $$$6n-1$$$ columns.

Unfortunately, Alice's eyesight really is quite bad, so she can only see one row or one column at a time, and doing so takes a lot of effort! Help Alice decipher Bob's code using as few observations as possible.

Interaction

The interactor will first send the integer $$$T=5000$$$, the number of test cases. Each test case goes as follows.

First, the interactor will send a positive integer $$$n$$$, the length of the string (where $$$1 \leq n \leq 10$$$ always). From here, you have three options.

You can send "ASK ROW <i>", where $$$1 \leq i \leq 8$$$. Then, the judge responds with a string of length $$$6n-1$$$, the characters in the $$$i$$$th row from the top.

You can send "ASK COL <j>", where $$$1 \leq j \leq 6n-1$$$. Then, the judge responds with $$$8$$$ lines, each containing a string of length 1, corresponding to the characters in the $$$j$$$th column from the left.

When ready, you can send "ANSWER <ans>" where ans is what you believe the original string to be. If your answer is correct, you proceed immediately to the next test case. If not, the judge gives you a Wrong Answer verdict, and no further communication will happen.

The judge will also give you a Wrong Answer verdict and cease communication if you attempt to make more than $$$20$$$ ASK queries in the same test case. We can prove that the task is always doable in $$$20$$$ or fewer ASK queries.

Scoring

If you got a Wrong Answer or did anything invalid, your score is $$$0$$$.

Otherwise, let $$$M$$$ be the maximum number of ASK queries used in any test case, across all test cases. You get more points the closer this is to optimal. Let $$$m$$$ be the judge's such number.

  • If your solution is correct, you get $$$50$$$ points
  • But if $$$M \leq 2m$$$, you get $$$75$$$ points instead.
  • But if $$$M=m$$$, you get $$$100$$$ points.
Note

Here is a sample interaction. The extra spaces and newlines are only added for illustration.


Judge Submission

1
3
ASK ROW 5
##..#.#...#..####
ASK COL 2
#
.
.
.
#
.
.
#
ANSWER 069