T = int(input()) for _ in range(T): N = int(input()) if N * (N + 1) // 2 & 1: print(-1) continue ans = [0] * N if N % 2 == 0: for i in range(N // 2): ans[i] = i & 1 for i in range(N // 2, N): ans[i] = (i + 1) & 1 else: n = 0 nn = N * (N + 1) // 4 for i in range(N, 0, -1): if n + i <= nn: ans[n - 1] = 1 print(*ans)