Penchick loves two things: square numbers and Hong Kong-style BBQ buns! For his…
- User
Penchick loves two things: square numbers and Hong Kong-style BBQ buns! For his birthday, Kohane wants to combine them with a gift: n BBQ buns arranged from left to right. There are 106 available fillings of BBQ buns, numbered from 1 to 106 . To ensure that Penchick would love this gift, Kohane has a few goals:
No filling is used exactly once; that is, each filling must either not appear at all or appear at least twice. For any two buns i and j that have the same filling, the distance between them, which is |i−j| , must be a perfect square∗ . Help Kohane find a valid way to choose the filling of the buns, or determine if it is impossible to satisfy her goals! If there are multiple solutions, print any of them.
∗ A positive integer x is a perfect square if there exists a positive integer y such that x=y2 . For example, 49 and 1 are perfect squares because 49=72 and 1=12 respectively. On the other hand, 5 is not a perfect square as no integer squared equals 5
Input Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤2⋅105 ). The description of the test cases follows.
The only line of each test case contains a single integer n (1≤n≤2⋅105 ) — the number of BBQ buns.
It is guaranteed that the sum of n over all test cases does not exceed 2⋅105 .
Output For each test case, if no valid choice of fillings exists, output −1 . Otherwise, output n integers, where the i -th integer represents the filling of the i -th BBQ bun. If there are multiple solutions, print any of them. solve this simpller problem where n <=100
- Assistant
To solve the problem where ( n \leq 100 ), we can use a straightforward approach based on the properties of perfect squares and pairing: