Conflict

시간 제한3초메모리 제한1024 MB

문제

In a desperate conflict, with a ruthless enemy...

This is an interactive problem.

As an elite spy fighting against a great evil empire, you have been tasked with $T$ separate reconnaissance missions. Each mission takes place in a different city of the empire, and your success is crucial to the resistance.

Every city is represented by $N$ key buildings, numbered from $1$ to $N$, connected by a network of roads. Each road connects two different buildings, and there may be multiple roads between the same pair of buildings. Your objective for each mission is to fully reconstruct the city's road network.

To achieve this, you are equipped with a special device capable of performing a sequential shutdown of the city's power grid. You can define a shutdown sequence $p_1, p_2, \dots, p_N$ --- a permutation of all $N$ buildings. At the exact moment when the power to building $p_i$ is cut, the device reports the number of roads that connect $p_i$ to other buildings that still have power.

You are allowed to use this device at most $N-1$ times during each mission.

제한

  • $1 \le T \le 1\,000$
  • $2 \le N \le 1\,000$
  • $0 \le M \le 10^4$
  • The sum of $N$ over all test cases is at most $2\,000$.
  • The sum of $M$ over all test cases is at most $10^4$.

힌트

After printing each query, you must flush the output buffer to ensure the interactor receives your output. Failing to do so can result in an unexpected verdict. You can flush the output by using the following methods:

  • In C++, call fflush(stdout) or cout.flush().
  • In Java, call System.out.flush().
  • In Python, call sys.stdout.flush().
  • In Kotlin, call System.out.flush().

For other languages, you should refer to the official documentation for your language.