CF2131B.Alternating Series

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

Alternating Series

You are given an integer nn. Call an array aa of length nn good if:

  • For all 1i<n1 \le i \lt n, aiai+1<0a_i \cdot a_{i+1} \lt 0 (i.e., the product of adjacent elements is negative).
  • For all subarrays^{\text{∗}} with length at least 22, the sum of all elements in the subarray is positive^{\text{†}}.

Additionally, we say a good array aa of length nn is better than another good array bb of length nn if [a1,a2,,an][|a_1|, |a_2|, \ldots, |a_n|] is lexicographically smaller^{\text{‡}} than [b1,b2,,bn][|b_1|, |b_2|, \ldots, |b_n|]. Note that z|z| denotes the absolute value of integer zz.

Output a good array of length nn such that it is better than every other good array of length nn.

^{\text{∗}}An array cc is a subarray of an array dd if cc can be obtained from dd by the deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end.

^{\text{†}}An integer xx is positive if x>0x \gt 0.

^{\text{‡}}A sequence aa is lexicographically smaller than a sequence bb if and only if one of the following holds:

  • aa is a prefix of bb, but aba \ne b; or
  • in the first position where aa and bb differ, the sequence aa has a smaller element than the corresponding element in bb.

Input

The first line contains an integer tt (1t5001 \leq t \leq 500) — the number of test cases.

The single line of each test case contains one integer nn (2n21052 \le n \le 2 \cdot 10^5) — the length of your array.

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5.

Output

For each test case, output nn integers a1,a2,,ana_1, a_2, \dots, a_n (109ai109-10^9 \leq a_i \leq 10^9), the elements of your array on a new line.

Note

In the first test case, because a1a2=2<0a_1 \cdot a_2 = -2 \lt 0 and a1+a2=1>0a_1 + a_2 = 1 \gt 0, it satisfies the two constraints. In addition, it can be shown that the corresponding b=[1,2]b = [1, 2] is better than any other good array of length 22.

Samples

2
2
3
-1 2
-1 3 -1

在线编程 IDE

建议全屏模式获得最佳体验