#C5856. Taco Array Construction

    ID: 49551 Type: Default 1000ms 256MiB

Taco Array Construction

Taco Array Construction

Given an integer \( n \), determine if it is possible to construct an array \( A \) of length \( n \) such that each element \( A[i] \) (for \( 1 \leq i \leq n \)) is an integer in the range \([1, n]\) and the sum of the array equals its product, i.e., \( \sum_{i=1}^{n}A[i] = \prod_{i=1}^{n}A[i] \). If there exists such an array, output one valid example; otherwise, output -1.

For this problem, valid outputs are predefined for specific values of \( n \):

  • When \( n = 1 \): output 1
  • When \( n = 3 \): output 1 2 1
  • When \( n = 5 \): output 1 2 3 6 3

For all other values of \( n \), output -1.

inputFormat

The first line contains a single integer \( T \) representing the number of test cases.

Each of the following \( T \) lines contains a single integer \( n \).

Input Format:

T
n1
n2
... 
nT

outputFormat

For each test case, output the resulting array or -1 if no valid array exists. For a valid array, print the numbers separated by spaces on a single line.

Output Format:

result1
result2
... 
resultT
## sample
3
1
3
5
1

1 2 1 1 2 3 6 3

</p>