E. Experiment - Anubis Edition!
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

This is an interactive problem.

This year, Alice decided to take an internship at the Gates to the Underworld, under the supervision of the Egyptian God of Death, Anubis.

She assists Anubis in weighing the hearts of the deceased in order to determine whose souls are worthy of entering the realm of the dead. Each heart is weighed against a feather of Ma'at, the goddess of truth, using a pair of balance scales. Those with hearts lighter than the feather get to enter the underworld; those with hearts heavier than the feather have their souls devoured by the goddess Ammit.

But Alice has an ambitious goal — what if they can precisely numerically measure the weight of each heart? Intrigued, Anubis challenges her to devise a feasible plan.

In order to comply with company policy, Alice is still required to use Anubis' balance scales. Balance scales have two pans, a left and a right. Alice can place any number of items in each pan, and once released, the scales will tip in the direction of the pan whose items have a greater total weight.

Alice can custom-order a special set of feathers from Ma'at. Each feather will have a known positive integer weight (in units), where Alice is free to specify the exact weight that she wants for each feather in her set.

Then, Anubis will test her. He will present to her a series of hearts, and she must precisely measure the weight of each heart using only the balance scales and her special set of feathers. The weight of each heart is guaranteed to be a positive integer when measured using the same units as Alice's feathers.

Ma'at will grant Alice at most $$$15$$$ feathers. Alice wants to maximize the number of units that these $$$15$$$ feathers can measure. Let's help her out!

Interaction

First things first, we want to make sure you have a high-level idea of what this problem is all about, without getting buried in technical details. Observe the "dialogue" interaction between Alice and Anubis shown here (at url https://imgur.com/a/HAJSRxk). This interaction is also what is encoded in the Sample Interaction section.

As we saw, the interaction comes in two phases: the "requesting", then the "testing".

First, output a positive integer $$$n$$$, meaning that you request a set of $$$n$$$ feathers, indexed from $$$1$$$ to $$$n$$$. Then, output a line of $$$n$$$ space-separated positive integers $$$w_1, w_2, w_3, \dots, w_n$$$, corresponding to the desired weight that you want each feather to have.

  • This $$$n$$$ can be at most $$$15$$$.
  • Each $$$w_i$$$ should be at most $$$10^8$$$
  • You may have multiple feathers with the same weight.

Next, output a positive integer $$$M$$$, corresponding to the claim, "Using only these feathers, I can accurately determine the weight of any heart, so long as its weight is a positive integer not greater than $$$M$$$." Ultimately, the higher this $$$M$$$, the higher your score will be. You may output $$$M$$$ up to $$$10^8$$$.

Based on your chosen feathers, Anubis will now challenge your claim. The judge first outputs a positive integer $$$T$$$, meaning that $$$T$$$ test cases will follow. This $$$T$$$ will be at most $$$100$$$.

For each test case, the judge selects a heart with some positive integer weight. We will give this heart an index of $$$0$$$, and lets its weight be denoted by $$$w_0$$$.

To use the balance scales, output a line containing only the word WEIGH. Then, output these four pieces of information, describing which items you want to put in each pan.

  • First, a positive integer $$$k_l$$$, the number of items going in the left pan.
  • Then, $$$k_l$$$ non-negative integers $$$l_1, l_2, \dots, l_{k_l}$$$, the indices of the items going in the left pan.
  • Next, a positive integer $$$k_r$$$, the number of items going in the right pan.
  • Finally, $$$k_r$$$ non-negative integers $$$r_1, r_2, \dots, r_{k_r}$$$, the indices of the items going in the right pan.
Each mentioned index should be between $$$0$$$ and $$$n$$$, inclusive. Recall that index $$$0$$$ corresponds to the heart whose weight you are currently trying to determine. Each item can only be placed in at most one pan (so no index should be included in both $$$l$$$ and $$$r$$$). You do not have to use all your feathers in every query.

Let $$$L$$$ and $$$R$$$ be the total weights of the items placed in the left and right pans, respectively. Formally, $$$$$$\begin{align*} L &= w_{l_1} + w_{l_2} + \dots + w_{l_{k_l}}, \\ R &= w_{r_1} + w_{r_2} + \dots + w_{r_{k_r}}. \end{align*} $$$$$$

The judge will give one of the following responses.

  • > if $$$L \gt R$$$
  • < if $$$L \lt R$$$
  • = if $$$L = R$$$
  • >:( if your query was invalid. Perhaps, for example,
    • You attempted to place an item in more than one pan.
    • You used an index not in the range $$$0$$$ to $$$n$$$
    • You did not provide exactly $$$k_l$$$ or $$$k_r$$$ items to put in each pan.

You may perform as many queries as you want, so long as all test cases are answered within the time limit.

When you are ready to report the weight of the heart, output a line containing only the word VERDICT, and then output one of the following:

  • If you believe that $$$w_0 \gt M$$$, output a line containing the words HEAVY
  • Otherwise, you believe that $$$1 \leq w_0 \leq M$$$, and you should output a line containing the word EXACT. Then, output another line containing a single positive integer, the value of $$$w_0$$$.
The judge will give one of the following responses.
  • :) if your answer is correct. If so, the judge immediately proceeds to the next test case.
  • >:( if your answer is incorrect, or if your reporting was otherwise invalid.

If the judge ever sends a >:( verdict, it will immediately terminate, and will send no further responses. In such a case, your program should terminate too.

Scoring

$$$$$$\begin{align*}

&\begin{array}{|l|} \hline \text{Constraints For All Subtasks} \\ \hline \text{If you receive a }\mathtt{:)}\text{ verdict on all test cases, then you will be awarded points based on how high your declared $M$ was.} \\ \hline \end{array}\\

&\begin{array}{|c|c|l|} \hline \text{Subtask} & \text{Points} & \text{Constraints} \\ \hline 1 & \mathbf{30} & M \geq 15 \\ \hline 2 & \mathbf{5} & M \geq 25 \\ \hline 3 & \mathbf{10} & M \geq 70 \\ \hline 4 & \mathbf{5} & M \geq 1000 \\ \hline 5 & \mathbf{20} & M \geq 32123 \\ \hline 6 & \mathbf{5} & M \geq 65456 \\ \hline 7 & \mathbf{15} & M \geq 7142857 \\ \hline 8 & \mathbf{10} & M \geq 14142135 \\ \hline \end{array}\\

\end{align*}$$$$$$

Example
Input
                    
                    
                
2
                    
                    
                    
                    
                    
<
                    
                    
                    
                    
                    
=
                    
                    
                    
:)
                    
                    
                    
                    
                    
>
                    
                    
:)
Output
6
1 1 2 3 5 8
15

WEIGH
3
1 3 6
2
0 5

WEIGH
2
4 5
2
0 2

VERDICT
EXACT
7

WEIGH
1
0
6
1 2 3 4 5 6

VERDICT
HEAVY
Note

The blank lines are only used here to illustrate the interaction between the contestant and the judge. Do not actually print these extra lines in your program.