Under construction

Still being built. Things may change

Ransom

Time limit2sMemory limit1024 MB

Summary
Find the hidden population of each of n cities by asking at most n queries, each returning the product of a chosen subset.
Level

Medium6 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

This is an interactive problem.

After Baldr was killed, Odin decided to bring him back to Asgard from Helheim, the realm of the dead. He gave his horse Sleipnir to Hermod and sent him to Hel, the goddess of the dead, to offer a ransom for Baldr. Hel agreed to release him if everything in the world, all things and creatures, wept for Baldr. That demand could not be met, so Hermod and Hel began discussing other ransom amounts.

Hermod said the world has nn cities, and every person living in them is ready to mourn Baldr. Let aia_i be the population of city ii. He refused to name the population of any city. He agreed to answer a few questions instead, each of the form: tell me the product ai1×ai2×…×aika_{i_1} \times a_{i_2} \times \ldots \times a_{i_k}, where i1,…,iki_1, \ldots, i_k are distinct indices of some of these cities. He allowed at most nn questions.

Help the ruler of the dead find how many people live in each city.

Hints

The number the judge returns after each query can be quite large.

For the program to work correctly, you must do the following after every output operation:

  • Pascal: flush(output);
  • C/C++: fflush(stdout);
  • Java: System.out.flush();
  • Python: sys.stdout.flush();

Also end every printed line with a newline character.

Examples1

  1. Example 1

    Input
    3 2
    2
    8
    4
    
    Expected output
    1 2
    2 3
    1 3
    answer: 1 2 4