-
Notifications
You must be signed in to change notification settings - Fork 638
Expand file tree
/
Copy pathP42_POSAND.py
More file actions
36 lines (35 loc) · 925 Bytes
/
P42_POSAND.py
File metadata and controls
36 lines (35 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def main():
t = int(input())
res = [2,3,1]
last = 3
check = 4
for _ in range(t):
n = int(input())
if n == 1:
print(1)
elif (n & (n-1)) == 0:
print(-1)
elif n <= last:
for i in range(n):
print(res[i], end=" ")
print()
else:
for i in range(last):
print(res[i], end=" ")
last += 1
while last <= n:
if last == check:
res.append(last + 1)
res.append(last)
print((last + 1), end=" ")
print(last, end=" ")
last += 2
check *= 2
else:
print(last, end=" ")
res.append(last)
last += 1
print()
last -= 1
return 0
main()