Under construction

Still being built. Things may change

Five Nights at Freddy's

Time limit2sMemory limit512 MB

Summary
Construct a cyclic sequence containing every camera so that repeats of camera i are at most a_i positions apart, or report that it is impossible.
Level

Hard8 of 10

Topics
Number theory, Greedy, Implementation
Solved
No attempts yet

Problem

Maria has finally got her dream job. She became a professional night guard at the Sky Tower. One of her duties is to report unwanted activity in the building. Fortunately, she can do her job without leaving her comfortable chair. All she has to do is keep track of the cameras installed in the skyscraper. To do so, she must handle nn different cameras, numbered from 11 to nn. She wants to create a transmission cycle in which she will process information from the cameras. She will watch the transmission from one camera for one minute and then switch to the next camera in the cycle. Every camera must appear at least once in the cycle. There are additional constraints. In the cycle, two consecutive appearances of camera ii cannot be more than aia_i positions apart. Fortunately for Maria, for every 1≤i<j≤n1 \le i < j \le n, at least one of aia_i and aja_j is a multiple of the other. If possible, help Maria create such a cycle with length at most 10610^6.

Input

The first line contains one integer Z≤50Z \le 50, the number of test cases described in the following lines.

The first line of each test case contains one integer nn, the number of cameras in the Sky Tower.

The next line describes the cameras. The ii-th number is the parameter aia_i of the ii-th camera.

Output

For each test case:

If it is impossible to construct such a cycle, the first and only line of the output should consist of the single word NIE.

If it is possible to construct such a cycle, output the single word TAK on the first line. The following line should contain a description of a transmission cycle. The first number mm is the length of the cycle. The next mm numbers are the camera numbers in the order they appear in the cycle.

If there are several possible answers, print any of them.

Constraints

  • n∈[1,105]n \in [1,10^5]
  • ai∈[1,105]a_i \in [1,10^5]

Examples1

  1. Example 1

    Input
    2
    3
    2 4 8
    5
    3 3 6 6 42
    
    Expected output
    TAK
    4 1 2 1 3
    NIE