Gildong is developing a game consisting of n stages numbered from 1 to n. The player starts the game from the 1-st stage and should beat the stages in increasing order of the stage number. The player wins the game after beating the n-th stage.

There is at most one checkpoint on each stage, and there is always a checkpoint on the 1-st stage. At the beginning of the game, only the checkpoint on the 1-st stage is activated, and all other checkpoints are deactivated. When the player gets to the i-th stage that has a checkpoint, that checkpoint is activated.

For each try of a stage, the player can either beat the stage or fail the stage. If they beat the i-th stage, the player is moved to the i+1-st stage. If they fail the i-th stage, the player is moved to the most recent checkpoint they activated, and they have to beat the stages after that checkpoint again.

For example, assume that n = 4 and the checkpoints are on the 1-st and 3-rd stages. The player starts at the 1-st stage. If they fail on the 1-st stage, they need to retry the 1-st stage because the checkpoint on the 1-st stage is the most recent checkpoint they activated. If the player beats the 1-st stage, they're moved to the 2-nd stage. If they fail it, they're sent back to the 1-st stage again. If they beat both the 1-st stage and the 2-nd stage, they get to the 3-rd stage and the checkpoint on the 3-rd stage is activated. Now whenever they fail on the 3-rd stage, or the 4-th stage after beating the 3-rd stage, they're sent back to the 3-rd stage. If they beat both the 3-rd stage and the 4-th stage, they win the game.

Gildong is going to build the stages to have equal difficulty. He wants you to find any series of stages and checkpoints using at most 2000 stages, where the [expected number](https://en.wikipedia.org/wiki/Expected_value) of tries over all stages is exactly k, for a player whose probability of beating each stage is exactly \cfrac{1}{2}.

Input

Each test contains one or more test cases. The first line contains the number of test cases t (1 ≤ t ≤ 50).

Each test case contains exactly one line. The line consists of a single integer k (1 ≤ k ≤ 10^{18}) — the expected number of tries over all stages Gildong wants to set for a player whose probability of beating each stage is exactly \cfrac{1}{2}.

Output

For each test case, print -1 if it's impossible to construct such a series of stages and checkpoints using at most 2000 stages.

Otherwise, print two lines. The first line should contain a single integer n (1 ≤ n ≤ 2000) – the number of stages. The second line should contain n integers, where the i-th integer represents whether the i-th stage has a checkpoint. The i-th integer should be 0 if the i-th stage doesn't have a checkpoint, and 1 if it has a checkpoint. Note that the first integer must be 1 according to the description.

Example

Input


4
1
2
8
12


Output


-1
1
1
4
1 1 1 1
5
1 1 0 1 1

Note

In the first and the second case, we can see that the 'easiest' series of stages is to have 1 stage with a checkpoint. This already requires 2 tries in expectation, so it is impossible to make it to require only 1 try.

In the third case, it takes 2 tries in expectation to beat each stage, and the player can always retry that stage without falling back to one of the previous stages if they fail it. Therefore the total expected number of tries is 8. Note that there exists an answer with fewer stages, but you are not required to minimize the number of stages used.

Source: codeforces | Difficulty: HARD
Tags: Probability

Constructive algorithms

Greedy algorithms

Complete search

Mathematics


Solutions:
t = int(input())
for _ in range(t):
	n = int(input())
	if n % 2 == 1:
		print(-1)
		continue
	ans = []
	tmp = 0
	for i in range(2, 62):
		if 1 << i & n:
			ans.append('1')
			for j in range(i - 2):
				ans.append('0')
			tmp += 1
	for i in range(tmp):
		ans.append('1')
	if 2 & n:
		ans.append('1')
	print(len(ans))
	print(' '.join(ans))


from sys import stdin, stdout
import math
input = stdin.readline
print2 = stdout.write

def Log2(x):
	return math.log10(x) / math.log10(2)

def most(x):
	i = 2
	while 1:
		if 2 ** i - 2 > x:
			return i - 1
		i += 1

def get_ints():
	return map(int, stdin.readline().split())

def get_list():
	return tuple(map(int, stdin.readline().split()))
for _ in range(int(input())):
	exp = int(input())
	if exp % 2:
		print(-1)
		continue
	total = 0
	true = most(exp)
	left = exp - (2 ** true - 2)
	levels = [1] + [0] * (true - 2)
	total += true - 1
	while left:
		cur = most(left)
		total += cur - 1
		left -= 2 ** cur - 2
		levels.extend([1] + [0] * (cur - 2))
	if true > 2000:
		print(-1)
		continue
	print(total)
	print(*levels)


ref_val = [2 ** i - 2 for i in range(2, 61)]
n = len(ref_val)
t = int(input())
for _ in range(t):
	k = int(input())
	if k % 2:
		print(-1)
	else:
		ptr = n - 1
		res = []
		while k:
			if k >= ref_val[ptr]:
				(num_times, num_rem) = divmod(k, ref_val[ptr])
				for j in range(num_times):
					res += ['1'] + ['0'] * ptr
				k -= num_times * ref_val[ptr]
			ptr -= 1
		print(len(res))
		print(' '.join(res))


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=300006, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += 1
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += 1
		self.temp.data = pre_xor

	def query(self, xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = xor & 1 << i
			if not val:
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				elif self.temp.right:
					self.temp = self.temp.right
			elif self.temp.right and self.temp.right.count > 0:
				self.temp = self.temp.right
			elif self.temp.left:
				self.temp = self.temp.left
			self.temp.count -= 1
		return xor ^ self.temp.data
for ik in range(int(input())):
	k = int(input())
	if k == 1 or k % 2 == 1:
		print(-1)
		continue
	if k == 2:
		print(1)
		print(1)
		continue
	k -= 2
	ans = []
	ans.append(1)
	t = 4
	while k > 0:
		while k > t:
			ans.append(0)
			k -= t
			t *= 2
		if k == 0:
			break
		if k == 2:
			ans.append(1)
			k = 0
			break
		if k == 4:
			ans.append(1)
			ans.append(1)
			k = 0
			break
		ans.append(1)
		k -= 2
		t = 4
	print(len(ans))
	print(*ans)


from sys import stdin
from math import pi
input = lambda : stdin.readline().strip()
ipnut = input
for i in range(int(input())):
	k = int(input())
	if k % 2:
		print(-1)
		continue
	s = bin(k)[2:]
	s = list(map(int, s))
	s.reverse()
	ans = []
	for i in range(len(s)):
		if s[i]:
			if i == 1:
				ans.append(1)
			else:
				ans += [1] + [0] * (i - 2) + [1]
	print(len(ans))
	print(*ans)


from bisect import bisect_left, bisect_right
t = int(input())
dp = [2]
while dp[-1] < 1000000000000000000:
	dp.append(dp[-1] * 2 + 2)
for _ in range(t):
	k = int(input())
	if k % 2 != 0:
		print(-1)
		continue
	ans = []
	while k > 0:
		ind = bisect_right(dp, k)
		ans.extend([1] + [0] * (ind - 1))
		k = k - dp[ind - 1]
	print(len(ans))
	print(*ans)


import math
from collections import Counter, defaultdict, deque

def f(n):
	if n % 2:
		return [-1]
	sz = 0
	s = ''
	i = len(a) - 1
	while i >= 0:
		if a[i] > n:
			i -= 1
			continue
		n -= a[i]
		s += '1'
		s += ''.join(['0' for j in range(i)])
		sz += i + 1
		if n == 0:
			break
	return [sz, s]
ti = 0
i = 2
a = []
while i <= 1e+18:
	ti += i
	a.append(ti)
	i *= 2
t = int(input())
result = []
for i in range(t):
	k = int(input())
	result.append(f(k))
for i in range(t):
	if result[i][0] == -1:
		print(result[i][0])
	else:
		print(result[i][0])
		for j in range(len(result[i][1])):
			print(result[i][1][j], end=' ')
		print()


t = int(input())
for _t in range(t):
	k = int(input())
	if k % 2:
		print(-1)
		continue
	p = 59
	step = 2 ** 60 - 2
	ans = ''
	l = 0
	while k:
		if k >= step:
			k -= step
			ans += '1 ' + '0 ' * (p - 1)
			l += p
		else:
			step = step // 2 - 1
			p -= 1
	if l > 2000:
		print(-1)
	else:
		print(l)
		print(ans.strip())


import sys
from math import gcd, sqrt, ceil, log2
from collections import defaultdict, Counter, deque
from bisect import bisect_left, bisect_right
import math
sys.setrecursionlimit(2 * 10 ** 5 + 10)
import heapq
from itertools import permutations
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
aa = 'abcdefghijklmnopqrstuvwxyz'

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def get_sum(bit, i):
	s = 0
	i += 1
	while i > 0:
		s += bit[i]
		i -= i & -i
	return s

def update(bit, n, i, v):
	i += 1
	while i <= n:
		bit[i] += v
		i += i & -i

def modInverse(b, m):
	g = math.gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def primeFactors(n):
	sa = []
	while n % 2 == 0:
		sa.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			sa.append(i)
			n = n // i
	if n > 2:
		sa.append(n)
	return sa

def seive(n):
	pri = [True] * (n + 1)
	p = 2
	while p * p <= n:
		if pri[p] == True:
			for i in range(p * p, n + 1, p):
				pri[i] = False
		p += 1
	return pri

def check_prim(n):
	if n < 0:
		return False
	for i in range(2, int(sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def getZarr(string, z):
	n = len(string)
	(l, r, k) = (0, 0, 0)
	for i in range(1, n):
		if i > r:
			(l, r) = (i, i)
			while r < n and string[r - l] == string[r]:
				r += 1
			z[i] = r - l
			r -= 1
		else:
			k = i - l
			if z[k] < r - i + 1:
				z[i] = z[k]
			else:
				l = i
				while r < n and string[r - l] == string[r]:
					r += 1
				z[i] = r - l
				r -= 1

def search(text, pattern):
	concat = pattern + '$' + text
	l = len(concat)
	z = [0] * l
	getZarr(concat, z)
	ha = []
	for i in range(l):
		if z[i] == len(pattern):
			ha.append(i - len(pattern) - 1)
	return ha

def mergeIntervals(arr):
	arr.sort(key=lambda x: x[0])
	m = []
	s = -10000
	max = -100000
	for i in range(len(arr)):
		a = arr[i]
		if a[0] > max:
			if i != 0:
				m.append([s, max])
			max = a[1]
			s = a[0]
		elif a[1] >= max:
			max = a[1]
	if max != -100000 and [s, max] not in m:
		m.append([s, max])
	return m

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def sol(n):
	seti = set()
	for i in range(1, int(sqrt(n)) + 1):
		if n % i == 0:
			seti.add(n // i)
			seti.add(i)
	return seti

def lcm(a, b):
	return a * b // gcd(a, b)

def moore_voting(l):
	count1 = 0
	count2 = 0
	first = 10 ** 18
	second = 10 ** 18
	n = len(l)
	for i in range(n):
		if l[i] == first:
			count1 += 1
		elif l[i] == second:
			count2 += 1
		elif count1 == 0:
			count1 += 1
			first = l[i]
		elif count2 == 0:
			count2 += 1
			second = l[i]
		else:
			count1 -= 1
			count2 -= 1
	for i in range(n):
		if l[i] == first:
			count1 += 1
		elif l[i] == second:
			count2 += 1
	if count1 > n // 3:
		return first
	if count2 > n // 3:
		return second
	return -1

def find_parent(u, parent):
	if u != parent[u]:
		parent[u] = find_parent(parent[u], parent)
	return parent[u]

def dis_union(n, e):
	par = [i for i in range(n + 1)]
	rank = [1] * (n + 1)
	for (a, b) in e:
		(z1, z2) = (find_parent(a, par), find_parent(b, par))
		if rank[z1] > rank[z2]:
			(z1, z2) = (z2, z1)
		if z1 != z2:
			par[z1] = z2
			rank[z2] += rank[z1]
		else:
			return (a, b)

def dijkstra(n, tot, hash):
	hea = [[0, n]]
	dis = [10 ** 18] * (tot + 1)
	dis[n] = 0
	boo = defaultdict(bool)
	check = defaultdict(int)
	while hea:
		(a, b) = heapq.heappop(hea)
		if boo[b]:
			continue
		boo[b] = True
		for (i, w) in hash[b]:
			if b == 1:
				c = 0
				if (1, i, w) in nodes:
					c = nodes[1, i, w]
					del nodes[1, i, w]
				if dis[b] + w < dis[i]:
					dis[i] = dis[b] + w
					check[i] = c
				elif dis[b] + w == dis[i] and c == 0:
					dis[i] = dis[b] + w
					check[i] = c
			elif dis[b] + w <= dis[i]:
				dis[i] = dis[b] + w
				check[i] = check[b]
			heapq.heappush(hea, [dis[i], i])
	return check

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res *= x
		x = x * x
		y = y >> 1
	return res
import sys
from math import ceil, log2
INT_MAX = sys.maxsize

def minVal(x, y):
	return x if x < y else y

def getMid(s, e):
	return s + (e - s) // 2

def RMQUtil(st, ss, se, qs, qe, index):
	if qs <= ss and qe >= se:
		return st[index]
	if se < qs or ss > qe:
		return INT_MAX
	mid = getMid(ss, se)
	return minVal(RMQUtil(st, ss, mid, qs, qe, 2 * index + 1), RMQUtil(st, mid + 1, se, qs, qe, 2 * index + 2))

def RMQ(st, n, qs, qe):
	if qs < 0 or qe > n - 1 or qs > qe:
		print('Invalid Input')
		return -1
	return RMQUtil(st, 0, n - 1, qs, qe, 0)

def constructSTUtil(arr, ss, se, st, si):
	if ss == se:
		st[si] = arr[ss]
		return arr[ss]
	mid = getMid(ss, se)
	st[si] = minVal(constructSTUtil(arr, ss, mid, st, si * 2 + 1), constructSTUtil(arr, mid + 1, se, st, si * 2 + 2))
	return st[si]

def constructST(arr, n):
	x = int(ceil(log2(n)))
	max_size = 2 * int(2 ** x) - 1
	st = [0] * max_size
	constructSTUtil(arr, 0, n - 1, st, 0)
	return st
t = int(input())
for _ in range(t):
	k = int(input())
	ans = []
	if k % 2 != 0:
		print(-1)
		continue
	ans = [1]
	su = 2
	k1 = 2
	while su - k != 0:
		su += 2 ** k1
		if su > k:
			su -= 2 ** k1
			su += 2
			ans.append(1)
			k1 = 2
			continue
		ans.append(0)
		k1 += 1
	k -= su
	ans += [1] * (k // 2)
	if len(ans) > 2000:
		print(-1)
		continue
	print(len(ans))
	print(*ans)


for t in range(int(input())):
	n = int(input())
	real = 0
	i = 2
	count = 0
	stack = []
	pre = 0
	(j, add, guna) = (0, 0, 0)
	while True:
		(i, pre, real) = (2, 0, 0)
		count = 0
		while real < n:
			pre = real
			real += 2 ** i
			i += 1
			count += 1
		stack.append(count)
		add += count
		guna += 1
		n -= pre + 2
		if n <= 0:
			break
	if n % 2 == 1:
		print(-1)
		continue
	print(add)
	c = []
	for i in range(guna):
		c.append(1)
		for k in range(stack[i] - 1):
			c.append(0)
	for i in range(add):
		print(c[i], end=' ')
	print()


import os, sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		k = int(input())
		if k % 2:
			print(-1)
			continue
		xx = bin(k)[2:]
		ls = []
		for i in range(len(xx) - 2):
			if xx[i] == '1':
				ls.extend([1] + [0] * max(0, len(xx) - 3 - i) + [1])
		if xx[len(xx) - 2] == '1':
			ls.append(1)
		print(len(ls))
		print(*ls)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def main():
	from sys import stdin
	from random import randint, choice, shuffle
	from functools import lru_cache
	input = stdin.readline
	for _ in range(int(input())):
		k = int(input())
		if k & 1:
			print(-1)
			continue
		ans = []
		while k:
			i = 2
			while (1 << i + 1) - 2 <= k:
				i += 1
			ans.append(1)
			for j in range(i - 2):
				ans.append(0)
			k -= (1 << i) - 2
		print(len(ans))
		print(*ans)
main()


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for k in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** (-10)
N = 100
dp = [0] * (N + 1)
dp[1] = 2
for i in range(2, N + 1):
	dp[i] = dp[i - 1] + 2 ** i
for _ in range(INT()):
	K = INT()
	ans = [1]
	K -= 2
	for i in range(N, 0, -1):
		if dp[i] <= K:
			(d, m) = divmod(K, dp[i])
			for _ in range(d):
				ans += [0] * (i - 1)
				ans += [1]
			K = m
	if K:
		print(-1)
	else:
		print(len(ans))
		print(*ans)


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	k = int(stdin.readline())
	if k % 2 == 1:
		stdout.write('-1\n')
	else:
		k = k // 2
		s = bin(k)[2:]
		l = len(s)
		answer = ''
		for i in range(l - 1):
			if s[i] == '1':
				answer += '1' + '1' + '0' * (l - i - 2)
		if s[l - 1] == '1':
			answer += '1'
		stdout.write(str(len(answer)) + '\n')
		stdout.write(' '.join(answer) + '\n')


def testcase():
	k = int(input())
	if k % 2 == 1:
		print(-1)
		return
	bit = 2
	i = -1
	ans = []
	bs = []
	while bit <= k:
		if bit & k != 0:
			if bit == 2:
				ans += [1]
			else:
				ans += [1] + [0] * i + [1]
		i += 1
		bit <<= 1
	print(len(ans))
	print(*ans)
	return
import sys, os
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
sys.setrecursionlimit(10 ** 5)
t = int(input())
for _ in range(t):
	testcase()


for _ in range(int(input())):
	k = int(input())
	if k % 2 == 1:
		print(-1)
		continue
	ch = 1
	r = []
	while k > 0:
		x = k
		s = 2
		c = 1
		while s <= x:
			if s + 2 ** (c + 1) <= x:
				s += 2 ** (c + 1)
				c += 1
			else:
				break
		if c == 0:
			print(-1)
			ch = 0
			break
		r += [1] + [0] * (c - 1)
		k -= 2 * (2 ** c - 1)
	if len(r) > 2000 or ch == 0:
		print(-1)
		continue
	print(len(r))
	print(*r)


def bit_arr(num):
	li = []
	while num:
		li.append(num % 2)
		num //= 2
	while len(li) < 64:
		li.append(0)
	return li
T = int(input())
for _ in range(T):
	k = int(input())
	ans = []
	if k % 2:
		print(-1)
		continue
	arr = bit_arr(k)
	ans = []
	for i in range(64):
		if arr[i]:
			if i == 1:
				ans.append(1)
			else:
				ans.append(1)
				ans.append(1)
				for j in range(i - 2):
					ans.append(0)
	print(len(ans))
	print(' '.join([str(i) for i in ans]))


def out(x):
	print('1', end=' ')
	for j in range(x - 1):
		print('0', end=' ')
p = 1
sum = 0
f = []
f.append(0)
for i in range(100):
	p = 2 * p
	f.append(p * (i + 1) - sum)
	sum += p * (i + 1)
T = int(input())
while T:
	T -= 1
	n = int(input())
	now = 90
	tot = 0
	len = 0
	a = []
	while now > 0:
		while n >= f[now]:
			len += now
			tot += 1
			n -= f[now]
			a.append(now)
		now -= 1
	if n != 0:
		print(-1)
	else:
		print(len)
		for i in range(tot):
			out(a[i])


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline()

def RL():
	return map(int, sys.stdin.readline().split())

def RLL():
	return list(map(int, sys.stdin.readline().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
for _ in range(N()):
	k = N()
	if k & 1:
		print(-1)
	else:
		res = ''
		now = 4
		while now - 2 <= k:
			now <<= 1
		while k:
			while now - 2 > k:
				now >>= 1
			res += bin(now >> 2)[2:]
			k -= now - 2
		print(len(res))
		print(' '.join(res))


(T,) = map(int, input().split())
for _ in range(T):
	(K,) = map(int, input().split())
	if K % 2 != 0:
		print(-1)
		continue
	X = []
	R = 0
	while 1:
		c = 4
		f = 1
		while R + c - 2 <= K:
			if f:
				f = 0
				X.append(1)
			else:
				X.append(0)
			c *= 2
		R += c // 2 - 2
		if R == K:
			break
	print(len(X))
	print(*X)


l = [2 ** i - 2 for i in range(2, 61)]

def main(n):
	s = 2
	r = [1]
	i = len(l) - 1
	while i >= 0:
		if s + l[i] > n:
			i -= 1
		else:
			s += l[i]
			r += [1] + [0] * i
	if s != n:
		return '-1'
	else:
		return f"{len(r)}\n{' '.join(map(str, r))}"
for _ in range(int(input())):
	print(main(int(input())))


def solve(k):
	if k % 2 == 1:
		print(-1)
		return
	ans = []
	left = k
	while left > 0:
		q = 0
		while pow(2, q + 2) - 2 <= left:
			q += 1
		q -= 1
		left -= pow(2, q + 2) - 2
		ans.append(1)
		while q > 0:
			ans.append(0)
			q -= 1
	if len(ans) > 2000:
		print(-1)
		return
	print(len(ans))
	print(*ans)
t = int(input())
for i in range(t):
	k = int(input())
	solve(k)


def oneLineArrayPrint(arr):
	print(' '.join([str(x) for x in arr]))

def calcTurnsForLZeroesInARow(L):
	return 4 * (2 ** L - 1)
t = int(input())
for _ in range(t):
	k = int(input())
	if k % 2 == 1:
		print(-1)
	else:
		ans = [1]
		k -= 2
		while k > 0:
			l = 0
			b = 2000
			while b > 0:
				while calcTurnsForLZeroesInARow(l + b) <= k:
					l += b
				b //= 2
			ans = ans + [0] * l
			k -= calcTurnsForLZeroesInARow(l)
			if k == 0:
				break
			ans.append(1)
			k -= 2
		print(len(ans))
		oneLineArrayPrint(ans)


t = int(input())

def func(arr, index, k):
	arr[index] = 2
	ans[index] = 1
	if k == 2:
		k -= 2
		return (index, k)
	for i in range(index + 1, n):
		arr[i] = (arr[i - 1] + 1) * 2
		if arr[i] == k:
			k -= arr[i]
			break
		elif arr[i] > k:
			arr[i] = 0
			k -= arr[i - 1]
			return (i, k)
	return (i, k)
while t > 0:
	t -= 1
	n = 2000
	k = int(input())
	if k % 2 != 0:
		print(-1)
		continue
	arr = [0 for x in range(n)]
	ans = [0 for x in range(n)]
	index = 0
	while k > 0:
		(index, k) = func(arr, index, k)
	print(index + 1)
	print(*ans[:index + 1])


two = []
cur = 1
for i in range(100):
	two.append(cur)
	cur *= 2
t = int(input())
for _ in range(t):
	k = int(input())
	if k % 2:
		print(-1)
		continue
	res = []

	def get(x):
		a = 0
		while 1:
			if two[a + 3] - 2 > x:
				break
			a += 1
		res.append('1')
		res.extend(['0'] * a)
		return x - two[a + 2] + 2
	while k:
		k = get(k)
	n = len(res)
	if n > 2000:
		print(-1)
		continue
	print(n)
	print(' '.join(res))


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = ''
	if n % 2:
		print(-1)
		continue
	n //= 2
	a = bin(n)[2:]
	n = len(a)
	for x in range(n - 1, 0, -1):
		if a[n - 1 - x] == '0':
			continue
		s += '1 ' + '0 ' * (x - 1) + '1 '
	if a[n - 1] == '1':
		s += '1 '
	print(len(s) // 2)
	print(s)


import io
import os
from collections import Counter, defaultdict, deque

def solve(K):
	if K % 2 == 1:
		return -1
	ans = []
	while K:
		n = 0
		p = 2
		while K - p >= 0:
			K -= p
			p *= 2
			n += 1
		ans.extend([1] + [0] * (n - 1))
		if len(ans) > 2000:
			return -1
	return str(len(ans)) + '\n' + ' '.join(map(str, ans))
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(K,) = [int(x) for x in input().split()]
	ans = solve(K)
	print(ans)


T = int(input())
for _ in range(T):
	N = int(input())
	stages = []
	if N % 2:
		print(-1)
	else:
		for i in range(59, 1, -1):
			if N >= 2 ** i - 2:
				N -= 2 ** i - 2
				tmp = [1] + [0] * (i - 2)
				stages.extend(tmp)
		if N > 0:
			while N:
				N -= 2
				stages.append(1)
		print(len(stages))
		print(*stages)


from bisect import bisect_left as bsl
powers = [2]
for s in range(60):
	powers.append(powers[-1] * 2)
newy = [powers[0]]
for s in range(1, len(powers)):
	newy.append(newy[-1] + powers[s])
	if newy[-1] >= 10 ** 18:
		break
for j in range(int(input())):
	k = int(input())
	if k % 2 == 1:
		print(-1)
	else:
		binrep = k - 2
		ans = [1]
		while binrep > 0:
			ind = min(bsl(newy, binrep), len(newy) - 1)
			if newy[ind] > binrep:
				ind -= 1
			for i in range(ind):
				ans.append(0)
			ans.append(1)
			binrep -= newy[ind]
		print(len(ans))
		print(*ans)


def main():
	k = int(input())
	if k & 1:
		print(-1)
		return
	k >>= 1
	ans = []
	for i in range(70, 0, -1):
		val = 2 ** i - 1
		while k >= val:
			ans.append(i)
			k -= val
	res = []
	for x in ans:
		res.append(1)
		for _ in range(1, x):
			res.append(0)
	print(len(res))
	print(*res, sep=' ')
	return
for _ in range(int(input())):
	main()


def main(k):
	result = None
	bk = str(bin(k))[2:]
	i = len(bk)
	result = []
	for (i, b) in enumerate(reversed(bk)):
		if b != '1':
			continue
		if i == 0:
			return -1
		if result and result[(i - 2) * 1:] == [0] * (i - 2):
			result.append(0)
			continue
		result.append(1)
		if i == 1:
			continue
		result.append(1)
		if i == 2:
			continue
		for j in range(i - 2):
			result.append(0)
	return result
t = int(input())
while t != 0:
	t -= 1
	k = int(input())
	sol = main(k)
	if sol is None or sol == -1:
		print(-1)
	else:
		print(len(sol))
		print(' '.join(map(str, sol)))


b = [2]
for i in range(62):
	b.append(b[-1] * 2 + 2)
for _ in range(int(input())):
	k = int(input())
	if k % 2:
		print(-1)
	else:
		q = []
		while k > 0:
			i = len(b) - 1
			while b[i] > k:
				i -= 1
			q.append(i)
			k -= b[i]
		n = sum(q) + len(q)
		if n <= 2000:
			print(n)
			for i in q:
				print('1' + ' 0' * i, end=' ')
			print()
		else:
			print(-1)


import sys
import bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def Golf():
	(n, *t) = map(int, open(0).read().split())

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def MI():
	return map(int, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def NLI(n):
	return [[int(i) for i in input().split()] for i in range(n)]

def NLI_(n):
	return [[int(i) - 1 for i in input().split()] for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RA():
	return map(int, open(0).read().split())

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def INP():
	N = 9
	n = random.randint(1, N)
	m = random.randint(1, n * n)
	A = [random.randint(1, n) for i in range(m)]
	B = [random.randint(1, n) for i in range(m)]
	G = [[] for i in range(n)]
	RG = [[] for i in range(n)]
	for i in range(m):
		(a, b) = (A[i] - 1, B[i] - 1)
		if a == b:
			continue
		G[a] += ((b, 1),)
		RG[b] += ((a, 1),)
	return (n, m, G, RG)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		a1 = naive(*inp)
		a2 = solve(*inp)
		if a1 == a2:
			print(inp)
			print('naive', a1)
			print('solve', a2)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
l_alp = string.ascii_lowercase
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()
show_flg = False
show_flg = True
ans = 0
for _ in range(I()):
	ans = 0
	n = I()
	N = n
	x = 1 << 63
	k = 63
	ans = []
	rt = []
	while x > 2:
		while n >= x - 2:
			n -= x - 2
			ans += (k - 1,)
			rt += (x - 2,)
		x >>= 1
		k -= 1
	for i in range(n):
		0
	if n != 0:
		print(-1)
		continue
	z = []
	print(sum(ans))
	for i in ans:
		print(1, end=' ')
		for j in range(i - 1):
			print(0, end=' ')
	print()


add = [2 ** n - 1 for n in range(64)]
for _ in range(int(input())):
	k = int(input())
	if k % 2:
		print(-1)
		continue
	k //= 2
	i = len(add) - 1
	ans = [1]
	k -= 1
	while k:
		if add[i] > k:
			i -= 1
		else:
			k -= add[i]
			ans += [0] * (i - 1) + [1]
	print(len(ans))
	print(*ans)


for i in range(int(input())):
	n = int(input())
	if n % 2 == 1:
		print(-1)
		continue
	cur = [2]
	while cur[-1] < n:
		cur.append((cur[-1] + 1) * 2)
	ans = 0
	res = []
	while n > 0:
		for i in range(len(cur) - 1, -1, -1):
			if cur[i] <= n:
				ans += i + 1
				res.extend([1] + [0] * i)
				n -= cur[i]
				break
	print(ans)
	print(*res)
	continue


def solve(k):
	if k & 1:
		print(-1)
		return
	if k == 2:
		print(1)
		print(1)
		return
	ans = [1]
	k >>= 1
	k -= 1
	if k & 1:
		ans.append(1)
	k >>= 1
	a = []
	i = 0
	while k:
		if k & 1:
			a.append(i)
		k >>= 1
		i += 1
	for x in a:
		ans.extend([0] * x)
		ans.append(1)
		ans.append(1)
	print(len(ans))
	print(*ans)
t = int(input())
for i in range(t):
	k = int(input())
	solve(k)


def find_zeros(k):
	i = 2
	while (1 << i + 1) - 2 <= k:
		i += 1
	return i - 2

def test_case():
	k = int(input())
	if k % 2 == 1:
		print('-1')
		return
	ans = '1 '
	k -= 2
	while k > 0:
		no_of_zeros = find_zeros(k)
		k -= (1 << no_of_zeros + 2) - 2
		ans += '0 ' * no_of_zeros + '1 '
	print(int(len(ans) / 2))
	print(ans)
tc = int(input())
for _ in range(tc):
	test_case()


t = int(input())
add = 4
arr = [2]
for i in range(70):
	arr += [arr[-1] + add]
	add *= 2
for _ in range(t):
	k = int(input())
	ans = [1]
	flag = 1
	while k != 0:
		flag = 0
		for i in range(69, -1, -1):
			if arr[i] <= k:
				ans += [0] * i + [1]
				flag = 1
				k -= arr[i]
		if flag == 0:
			ans = -1
			break
	if ans != -1:
		ans.pop()
		print(len(ans))
		print(*ans)
	else:
		print(ans)


for _ in range(int(input())):
	n = int(input())
	if n % 2:
		print(-1)
		continue
	a = []
	while n:
		x = 2
		while n >= x:
			a += [int(x == 2)]
			n -= x
			x *= 2
	print(len(a))
	print(*a)


t = int(input())
while t > 0:
	t -= 1
	a = []
	k = int(input())
	sss = ''
	if k % 2 == 1:
		print(-1)
	else:
		s = 0
		while k > 0:
			if s == 0:
				s = 2
				sss += '1 '
				a.append(1)
			else:
				p = s
				while s < k:
					p = s
					s = s * 2 + 2
					if s < k:
						sss += '0 '
						a.append(0)
				k -= p
				s = 0
		print(len(a))
		print(sss)


t = int(input())
al = [2]
for i in range(100):
	al.append(al[-1] * 2 + 2)
for q in range(t):
	k = int(input())
	if k % 2 == 1:
		print(-1)
	else:
		mas = []
		while k > 0:
			y = 0
			while al[y] <= k:
				y += 1
			y -= 1
			mas.append(y)
			k -= al[y]
		z = 0
		for i in mas:
			z += i + 1
		print(z)
		for i in mas:
			print(1, end=' ')
			for j in range(i):
				print(0, end=' ')
		print()


for _ in range(int(input())):
	n = int(input())
	if n % 2:
		print(-1)
	else:
		out = ''
		while n:
			out += '1'
			i = 0
			x = 2
			while 2 * (x + 1) <= n:
				x = 2 * (x + 1)
				i += 1
			out += '0' * i
			n -= x
		l = len(out)
		if l <= 2000:
			print(l)
			print(*list(out))
		else:
			print(-1)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
import time
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict as dd, deque as dq, Counter as dc
import math, string
start_time = time.time()

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())

def getMat(n):
	return [getInts() for _ in range(n)]

def isInt(s):
	return '0' <= s[0] <= '9'
MOD = 998244353

def solve():
	N = getInt()
	if N % 2 == 1:
		print(-1)
		return
	ops = []
	curr = 1
	while True:
		tmp = 2 * (pow(2, curr) - 1)
		if tmp > 10 ** 18:
			break
		ops.append(tmp)
		curr += 1
	ans = []
	while N:
		idx = len(ops) - 1
		while ops[idx] > N:
			idx -= 1
		N -= ops[idx]
		ans.append(1)
		for i in range(idx):
			ans.append(0)
	print(len(ans))
	print(*ans)
	return
for _ in range(getInt()):
	solve()


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa = ifa[::-1]

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def lowbit(n):
	return n & -n

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class DSU:

	def __init__(self, n):
		self.c = [-1] * n

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def find(self, x):
		if self.c[x] < 0:
			return x
		self.c[x] = self.find(self.c[x])
		return self.c[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] < self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

	def size(self, x):
		return -self.c[self.find(x)]

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return flag

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d

def GP(it):
	return [[ch, len(list(g))] for (ch, g) in groupby(it)]

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None

def nb(i, j):
	for (ni, nj) in [[i + 1, j], [i - 1, j], [i, j - 1], [i, j + 1]]:
		if 0 <= ni < n and 0 <= nj < m:
			yield (ni, nj)

@bootstrap
def gdfs(r, p):
	if len(g[r]) == 1 and p != -1:
		yield None
	for ch in g[r]:
		if ch != p:
			yield gdfs(ch, r)
	yield None
t = N()
for i in range(t):
	k = N()
	if k & 1:
		print(-1)
		continue
	n = len(bin(k)) - 2
	ans = []
	for i in range(n - 1, 0, -1):
		if k & 1 << i:
			if i == 1:
				ans.append(1)
			else:
				ans.append(1)
				ans += [0] * (i - 2)
				ans.append(1)
	print(len(ans))
	print(*ans)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	k = int(input())
	ans = []
	if k % 2 == 1:
		print(-1)
	else:
		while k > 0:
			check = 0
			s = 1
			now = 0
			while check + 2 ** s <= k:
				check += 2 ** s
				s += 1
			ans.append(1)
			for l in range(s - 2):
				ans.append(0)
			k -= check
		print(len(ans))
		print(' '.join(map(str, ans)))


from collections import deque
import sys
serie = ''
d = deque()
n = 2
d.append(n)
while n < 10 ** 18:
	n = 2 * n + 2
	d.append(n)
r = 58

def binarySearch(l, r, x):
	if r >= l:
		mid = l + (r - l) // 2
		if d[mid] == x:
			return mid
		elif d[mid] > x:
			return binarySearch(l, mid - 1, x)
		else:
			return binarySearch(mid + 1, r, x)
	else:
		return l - 1

def p(x, s=''):
	if x == 0:
		return s
	i = binarySearch(0, r, x)
	s += '1 ' + '0 ' * i
	x -= d[i]
	return p(x, s)
t = int(sys.stdin.readline().strip())
while t > 0:
	k = int(sys.stdin.readline().strip())
	serie = ''
	if k % 2 == 1:
		print(-1)
	else:
		s = p(k)
		print(len(s) // 2)
		print(s)
	t -= 1


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	k = int(input())
	if k % 2 == 1:
		print(-1)
		continue
	k -= 2
	ANS = []
	now = 2
	while k:
		if now == 2:
			ANS.append(1)
			k -= now
			now *= 2
		elif now <= k:
			ANS.append(0)
			k -= now
			now *= 2
		else:
			now = 2
	ANS = [1] + list(reversed(ANS))
	print(len(ANS))
	print(*ANS[::-1])


import os
import sys
from io import BytesIO, IOBase
import math
import bisect

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c

def calmaxpow(n, i):
	f = 0
	while n % i == 0:
		n //= i
		f += 1
	return f
l = [2]
while l[-1] <= 1000000000000000000:
	l.append(2 * (l[-1] + 1))
for xyz in range(0, int(input())):
	n = int(input())
	if n % 2:
		print(-1)
	else:
		ans = []
		while n > 0:
			t = bisect.bisect(l, n)
			if l[t] > n:
				ans.append(t - 1)
				n -= l[t - 1]
			else:
				ans.append(t)
				n -= l[t]
		print(sum(ans) + len(ans))
		for i in ans:
			print(1, end=' ')
			for j in range(0, i):
				print(0, end=' ')
		print('')


for _ in range(int(input())):
	k = int(input())
	if k % 2:
		print(-1)
	else:
		ans = []
		k //= 2
		while k:
			cur = k.bit_length()
			while 2 ** cur - 1 < k:
				cur += 1
			while 2 ** cur - 1 > k:
				cur -= 1
			ans += [1] + [0] * (cur - 1)
			k -= 2 ** cur - 1
		if len(ans) > 2000:
			print(-1)
		else:
			print(len(ans))
			print(*ans)


from math import log2
t = int(input())
for z in range(t):
	n = int(input())
	if n % 2 != 0:
		print(-1)
		continue
	ans = [0] * 2000
	ans[0] = 1
	count = 0
	while n > 0:
		c = 1
		term = 4
		while term - 2 <= n:
			c += 1
			term *= 2
		count += c - 1
		ans[count] = 1
		n = n - (term // 2 - 2)
	print(count)
	print(*ans[:count])


for i in range(int(input())):
	k = int(input())
	if k % 2:
		print(-1)
	else:
		ans = [1]
		i = 2
		k -= i
		while k > 0:
			if i * 2 <= k:
				i *= 2
				k -= i
				ans.append(0)
			else:
				i = 2
				k -= 2
				ans.append(1)
		print(len(ans))
		print(*ans)


pows = [2]
inf = 10 ** 18
while True:
	pows.append(2 * pows[-1] + 2)
	if pows[-1] > inf:
		break
lnpws = len(pows)
for tt in range(int(input())):
	k = int(input())
	if k & 1:
		print(-1)
		continue
	d = []
	for i in range(lnpws - 1, -1, -1):
		while k >= pows[i]:
			k -= pows[i]
			d.append(i + 1)
		if k == 0:
			break
	nn = sum(d)
	if nn > 2000:
		print(-1)
		continue
	ans = ['0' for _ in range(nn)]
	ind = 0
	for d_ in d:
		ans[ind] = '1'
		ind += d_
	print(nn)
	print(' '.join(ans))


for _ in range(int(input())):
	k = int(input())
	if k & 1:
		print(-1)
		continue
	ans = []
	cur = 0
	i = 0
	while k:
		k >>= 1
		i += 1
		if not k & 1:
			continue
		ans.append(1)
		ans += [0] * (i - 2)
		if i > 1:
			ans.append(1)
	print(len(ans))
	print(*ans)


for nt in range(int(input())):
	n = int(input())
	if n % 2:
		print(-1)
	else:
		ans = ''
		k = n
		while True:
			ans += '1'
			k = k - 2
			i = 2
			if not k:
				print(len(ans))
				print(' '.join(list(ans)))
				break
			while 2 ** i < k:
				ans += '0'
				k -= 2 ** i
				i += 1


t = int(input())
for i in range(t):
	n = int(input())
	if n % 2 == 0:
		k = str(bin(n))[2:]
		k = k[::-1]
		ss = 0
		k = k[1:]
		ans = []
		while n > 2:
			ss += 1
			if ss < len(k) and k[ss] == '1':
				n -= 2 ** (ss + 1)
				ans += [1] * 2 + [0] * (ss - 1)
		if n == 2:
			ans += [1]
		print(len(ans))
		print(*ans)
	else:
		print(-1)


import sys
from sys import stdin
tt = int(stdin.readline())
for loop in range(tt):
	k = int(stdin.readline())
	ans = []
	if k % 2 == 1:
		print(-1)
		continue
	tmp = 2
	while k > 2:
		if k & 2 ** tmp > 0:
			ans.append(1)
			ans.append(1)
			for i in range(tmp - 2):
				ans.append(0)
			k ^= 2 ** tmp
		tmp += 1
	if k == 2:
		ans.append(1)
	if len(ans) <= 2000:
		print(len(ans))
		print(*ans)
	else:
		print(-1)


from sys import stdin, stdout
import heapq
from collections import defaultdict
import math
import bisect
import os

def main():
	t = int(stdin.readline())
	x = 4
	arr = []
	while x < 10 ** 18:
		arr.append(x - 2)
		x *= 2
	arr.reverse()
	for _ in range(t):
		n = int(stdin.readline())
		if n % 2 == 1:
			stdout.write('-1\n')
			continue
		ans = []
		for (i, x) in enumerate(arr):
			while x * 2 + 2 > n and x <= n:
				n -= x
				ans.append(1)
				for _ in range(len(arr) - i - 1):
					ans.append(0)
				if n == 0:
					break
		stdout.write(str(len(ans)) + '\n')
		stdout.write(' '.join([str(x) for x in ans]) + '\n')
main()


from collections import defaultdict, deque
import sys
import bisect
input = sys.stdin.readline
mod = 1000000007
t = int(input())
for tests in range(t):
	k = int(input())
	if k % 2 == 1:
		print(-1)
		continue
	ans = []
	now = 2
	while k:
		if now == 2:
			ans.append(1)
			k -= now
			now *= 2
		elif now < k:
			ans.append(0)
			k -= now
			now *= 2
		else:
			now = 2
	print(len(ans))
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	if n & 1:
		print(-1)
		continue
	l = [1]
	now = 2
	left = n - 2
	while left:
		tot = now * 2
		if tot <= left:
			l.append(0)
			left -= tot
			now = tot
		else:
			l.append(1)
			left -= 2
			now = 2
	print(len(l))
	print(*l)


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	q = int(input())
	if q % 2 == 1:
		print(-1)
	else:
		w = [1]
		i = 2
		q -= 2
		while q > 0:
			if 2 * i < q:
				i *= 2
				q -= i
				w.append(0)
			else:
				i = 2
				q -= 2
				w.append(1)
		print(len(w))
		print(*w)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from bisect import bisect_left as bsl
powers = [2]
for s in range(60):
	powers.append(powers[-1] * 2)
newy = [powers[0]]
for s in range(1, len(powers)):
	newy.append(newy[-1] + powers[s])
	if newy[-1] >= 10 ** 18:
		break
for j in range(int(input())):
	k = int(input())
	if k % 2 == 1:
		print(-1)
	else:
		binrep = k - 2
		ans = [1]
		while binrep > 0:
			ind = min(bsl(newy, binrep), len(newy) - 1)
			if newy[ind] > binrep:
				ind -= 1
			for i in range(ind):
				ans.append(0)
			ans.append(1)
			binrep -= newy[ind]
		print(len(ans))
		print(*ans)


t = int(input())
for _ in range(t):
	k = int(input())
	if k % 2 == 1:
		print(-1)
		continue
	binary = list()
	while k > 0:
		(k, digit) = divmod(k, 2)
		binary.append(digit)
	blocks = list()
	count = 0
	for i in range(len(binary)):
		if binary[i] == 1:
			count += i
			blocks.append(1)
			blocks.append(i - 1)
	print(count)
	for b in blocks:
		if b > 0:
			print(1, end=' ')
			for _ in range(b - 1):
				print(0, end=' ')
	print()


import sys
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
di = [[-1, 0], [1, 0], [0, 1], [0, -1]]

def string(s):
	return ''.join(s)

def fori(n):
	return [fi() for i in range(n)]

def inc(d, c, x=1):
	d[c] = d[c] + x if c in d else x

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def gtc(tc, ans):
	print('Case #' + str(tc) + ':', ans)

def cil(n, m):
	return n // m + int(n % m > 0)

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j, n, m):
	return 0 <= i < n and 0 <= j < m

def bo(i):
	return ord(i) - ord('a')

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)
t = fi()
while t > 0:
	t -= 1
	n = fi()
	c = 2
	ans = '1'
	while n >= 2:
		while c <= n:
			if (c + 1) * 2 > n:
				break
			c = (c + 1) * 2
			ans += '0'
		n -= c
		c = 2
		if n >= 2:
			ans += '1'
	if n % 2:
		print(-1)
	else:
		for i in range(n // 2):
			ans += '1'
		print(len(ans))
		print(*list(ans))


for test in range(int(input())):
	n = int(input())
	if n % 2 == 1:
		print(-1)
	else:
		a = []
		while n != 0:
			x = 2
			cnt = 0
			while x - 2 <= n:
				cnt += 1
				x *= 2
			x //= 2
			cnt -= 1
			n -= x - 2
			a.append(1)
			for i in range(cnt - 1):
				a.append(0)
		print(len(a))
		for elem in a:
			print(elem, end=' ')
		print()


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(ii()):
		k = ii()
		if k % 2 == 1:
			print(-1)
		else:
			ans = 0
			li = []
			for i in range(60, 1, -1):
				step = k // ((1 << i) - 2)
				for j in range(step):
					li.append(1)
					for k1 in range(i - 2):
						li.append(0)
				k = k % ((1 << i) - 2)
				if k == 0:
					break
			print(len(li))
			print(' '.join(map(str, li)))

def mpin():
	return map(int, input().split())

def lmpin():
	return list(mpin())

def ii():
	return int(input())

def gridi(h, w):
	return [lmpin() for i in range(h)]

def gridstr(h, w):
	return [list(input()) for i in range(h)]

def zero1(h):
	return [0 for i in range(h)]

def zero2(h, w):
	return [[0 for j in range(w)] for i in range(h)]
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


tt = int(input())
for ii in range(tt):
	k = int(input())
	if k % 2 == 1:
		print(-1)
		continue
	num = k
	res = [0] * 10007
	d = -1
	for i in range(59, 1, -1):
		temp = (1 << i) - 2
		while num > 0:
			num -= temp
			d += 1
			res[d] = i
		if num == 0:
			break
		num += temp
		d -= 1
		res[d + 1] = 0
	ans = []
	for i in range(d + 1):
		ans.append(1)
		for i in range(1, res[i] - 1):
			ans.append(0)
	print(len(ans))
	for i in ans:
		print(i, end=' ')
	print()


tries = [(i, 2 ** (i + 1) - 2) for i in range(1, 60)]
tries.reverse()
t = int(input())
for _ in range(t):
	n = int(input())
	if n % 2 == 1:
		print(-1)
		continue
	stages = []
	x = []
	for (i, j) in tries:
		while j <= n:
			stages += [1] + [0] * (i - 1)
			n -= j
			x.append(j)
	print(len(stages))
	print(*stages)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	k = int(input())
	if k % 2:
		print(-1)
		continue
	res = []
	for i in range(60, 1, -1):
		x = 1 << i
		if k & x:
			res += [1] + [0] * (i - 2) + [1]
			k -= x
	res += [1] * (k // 2)
	print(len(res))
	print(*res)


import bisect
A = []
v = 2
mv = 2000
for i in range(mv + 1):
	v = v * 2
	A.append(v)

def main():
	T = int(input())
	for _ in range(T):
		k = int(input())
		n = 0
		ans = []
		if k % 2 != 0:
			print(-1)
		else:
			while k > 0 and n <= 2000:
				n = n + 1
				ans.append(1)
				k = k - 2
				for i in range(mv + 1):
					if A[i] > k or n > 2000:
						break
					n = n + 1
					k = k - A[i]
					ans.append(0)
			if n >= 2000:
				print(-1)
			else:
				print(n)
				print(*ans)
main()


for _ in range(int(input())):
	n = int(input())
	a = []
	if n % 2 == 1:
		print(-1)
		continue
	if n <= 4000:
		print(n // 2)
		print('1 ' * (n // 2))
		continue
	while n > 0:
		a.append(1)
		n -= 2
		s = 2
		while n > s * 2:
			a.append(0)
			s *= 2
			n -= s
	if len(a) <= 2000:
		print(len(a))
		print(*a, end=' ')
	else:
		print(-1)


import sys
import math
t = int(sys.stdin.readline())
for _ in range(t):
	k = int(sys.stdin.readline())
	if k < 2 or k % 2 == 1:
		print(-1)
		continue
	zeroList = [2]
	while zeroList[-1] < 10 ** 19:
		zeroList.append(2 * zeroList[-1] + 2)
	result = [1]
	k -= 2
	while len(result) < 2002 and k > 0:
		for idx in range(len(zeroList) - 1):
			if zeroList[idx] <= k and k < zeroList[idx + 1]:
				k -= zeroList[idx]
				for _ in range(idx):
					result.append(0)
				result.append(1)
				continue
	if len(result) > 2000:
		print(-1)
	else:
		print(len(result))
		for num in result:
			sys.stdout.write(str(num) + ' ')
		print()


T = int(input())
for _ in range(T):
	k = int(input())
	if k % 2:
		print(-1)
		continue
	res = [(1, 1)]
	k -= 2
	for u in range(60, 1, -1):
		p = 2 ** (u + 1) - 2
		if k // p:
			res.append((u, k // p))
		k %= p
	res.append((1, k // 2))
	ls = []
	for (u, cc) in res:
		ls += sum([[0] * (u - 1) + [1]] * cc, [])
	print(len(ls))
	print(*ls)


from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
	k = int(input())
	if k % 2:
		print(-1)
		continue
	val = bin(k)[2:][::-1]
	arr = []
	for i in range(len(val)):
		if val[i] == '1':
			arr.append(1)
			if i != 1:
				for i in range(i - 2):
					arr.append(0)
				arr.append(1)
	print(len(arr))
	print(*arr)


import math

def solve(a, lst):
	a = int(a)
	if a == 0:
		print(len(lst))
		print(' '.join(lst))
		return
	if a % 2 == 1 or a < 0:
		print('-1')
		return
	currSum = 0
	toAdd = 2
	while currSum + toAdd <= a:
		currSum += toAdd
		toAdd *= 2
		lst.append('0')
	lst[-1] = '1'
	remain = a - currSum
	solve(remain, lst)
n = int(input())
for i in range(n):
	num = int(input())
	num -= 2
	arr = ['1']
	solve(num, arr)


T = int(input())

def solve():
	N = int(input())
	if N % 2 == 1:
		print(-1)
		return
	E = [0, 2]
	while len(E) <= 2000:
		E.append(2 * E[-1] + 2)
	reverse_lookup = {}
	for i in range(len(E)):
		reverse_lookup[E[i]] = i
	idxes = []
	while N > 0:
		choose_idx = -1
		jump = 2000
		while jump > 0:
			while choose_idx + jump < len(E) and E[choose_idx + jump] <= N:
				choose_idx += jump
			jump //= 2
		choose = E[choose_idx]
		idxes.append(choose_idx)
		N -= choose
	ans = []
	for idx in idxes:
		ans.append(1)
		ans.extend([0] * (idx - 1))
	print(len(ans))
	print(' '.join([str(x) for x in ans]))
for _ in range(T):
	solve()


t = int(input())
chisls = [2 ** (i + 1) - 2 for i in range(1, 72)]
for i in range(t):
	n = int(input())
	if n % 2 == 1:
		print(-1)
	else:
		data = [1]
		n -= 2
		p = len(chisls) - 1
		while n > 0:
			while chisls[p] > n:
				p -= 1
			while n >= chisls[p]:
				data += [1] + [0 for j in range(p)]
				n -= chisls[p]
			if len(data) > 2000:
				break
		if len(data) > 2000:
			print(-1)
		else:
			print(len(data))
			print(*data)


import sys
input = sys.stdin.readline
t = int(input())
base = []
for i in range(0, 100):
	base.append(pow(2, i + 1) - 2)
for _ in range(t):
	k = int(input())
	ans = []
	if k % 2 == 1:
		print('-1')
		continue
	for i in range(99, 0, -1):
		if k >= base[i]:
			num = k // base[i]
			k = k % base[i]
			ans += ([1] + [0] * (i - 1)) * num
	print(len(ans))
	print(*ans)


import sys
from math import pow
for _ in range(int(sys.stdin.readline())):
	a = int(sys.stdin.readline())
	if a % 2 != 0:
		print(-1)
		continue
	v = []
	while a > 0:
		n = 2
		c = 1
		ln = 1
		while a >= n:
			ln = n
			n = 2 * n + 2
			c += 1
		c -= 1
		a -= ln
		v += ['1'] + ['0'] * (c - 1)
	if len(v) < 2001:
		print(len(v))
		print(' '.join(v))
	else:
		print(-1)


def read_int():
	return int(input())

def read_ints():
	return map(int, input().split(' '))
t = read_int()
a = [2]
while a[-1] < 1e+18:
	a.append(a[-1] * 2 + 2)
for case_num in range(t):
	n = read_int()
	if n % 2 == 1:
		print(-1)
		continue
	ans = []
	pos = len(a) - 1
	while n > 0:
		while a[pos] > n:
			pos -= 1
		n -= a[pos]
		ans += [1] + [0] * pos
	print(len(ans))
	print(' '.join(map(str, ans)))


import bisect

def solve(seq, k):
	n = len(seq)
	res = []
	while k > 0:
		idx = bisect.bisect_right(seq, k) - 1
		if idx == 0:
			break
		res.append(1)
		res += (idx - 1) * [0]
		k -= seq[idx]
	return res
T = int(input())
seq = []
power_2 = 2
while power_2 - 2 < 10 ** 18:
	seq.append(power_2 - 2)
	power_2 *= 2
for t in range(T):
	k = int(input())
	if k % 2 == 1:
		print(-1)
	else:
		res = solve(seq, k)
		print(len(res))
		print(' '.join(map(str, res)))


from sys import stdin
lst = [2, 6, 14, 30, 62, 126, 254, 510, 1022, 2046, 4094, 8190, 16382, 32766, 65534, 131070, 262142, 524286, 1048574, 2097150, 4194302, 8388606, 16777214, 33554430, 67108862, 134217726, 268435454, 536870910, 1073741822, 2147483646, 4294967294, 8589934590, 17179869182, 34359738366, 68719476734, 137438953470, 274877906942, 549755813886, 1099511627774, 2199023255550, 4398046511102, 8796093022206, 17592186044414, 35184372088830, 70368744177662, 140737488355326, 281474976710654, 562949953421310, 1125899906842622, 2251799813685246, 4503599627370494, 9007199254740990, 18014398509481982, 36028797018963966, 72057594037927934, 144115188075855870, 288230376151711742, 576460752303423486, 1152921504606846974]
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	if n % 2 == 1:
		print(-1)
	else:
		n -= 2
		counter = 0
		sizes = []
		for i in range(len(lst) - 1, -1, -1):
			while lst[i] <= n:
				n -= lst[i]
				sizes.append(i)
				if n == 0:
					break
		print(1 + sum(sizes) + len(sizes))
		print(1, end='')
		for s in sizes:
			print(' 0' * s + ' 1', end='')
		print()


for _ in range(int(input())):
	k = int(input())
	if k & 1:
		print('-1')
	else:
		p = [2]
		s = ''
		for i in range(1, 60):
			p.append(p[len(p) - 1] * 2 + 2)
		for i in range(59, -1, -1):
			while k >= p[i]:
				k -= p[i]
				s += '1' + '0' * i
		print(len(s))
		print(' '.join(s))


import sys, os
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

def solve_(k):
	if k % 2 == 1:
		return []
	k = k - 2
	bkk = []
	blocks = [(i - 2, 2 ** i - 2) for i in range(2, 60)]
	while blocks:
		if blocks[-1][1] > k:
			blocks.pop()
			continue
		(zeroes, deduct) = blocks[-1]
		k -= deduct
		bkk.append(zeroes)
	console(k)
	res = [1]
	for bk in bkk:
		res += [0] * bk + [1]
	return res

def console(*args):
	print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)
	pass
ONLINE_JUDGE = False
if os.path.exists('input.txt'):
	ONLINE_JUDGE = True
if ONLINE_JUDGE:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def console(*args):
		pass

def solve(*args):
	if not ONLINE_JUDGE:
		console('----- solving ------')
		console(*args)
		console('----- ------- ------')
	return solve_(*args)
if True:
	inp = iter(sys.stdin.buffer.readlines())
	input = lambda : next(inp)
else:
	input = sys.stdin.buffer.readline
for case_num in range(int(input())):
	k = int(input())
	res = solve(k)
	if len(res) == 0:
		print(-1)
	else:
		print(len(res))
		print(*res)


def ff(x):
	izn = 2
	ob = 2
	ot = '1'
	x = x - 2
	while True:
		izn *= 2
		ob += izn
		if x - izn >= 0:
			x = x - izn
			ot += '0'
		else:
			return (ot, x)
n = int(input())
for i in range(n):
	k = int(input())
	if k % 2 != 0:
		print(-1)
	else:
		ott = ''
		while k > 0:
			(otv, k) = ff(k)
			ott += otv
		print(len(ott))
		print(' '.join(list(ott)))


import sys
import math

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()

def FACT(n, mod):
	s = 1
	facts = [1]
	for i in range(1, n + 1):
		s *= i
		s %= mod
		facts.append(s)
	return facts[n]

def C(n, k, mod):
	return FACT(n, mod) * pow(FACT(k, mod) * FACT(n - k, mod) % mod, mod - 2, mod) % mod
t = II()
for q in range(t):
	k = II()
	if k % 2 == 1:
		print(-1)
	else:
		temp = list(bin(k)[2:-1])
		ans = []
		for i in range(len(temp)):
			if temp[i] == '1':
				ans.append(1)
				ans += [0] * (len(temp) - i - 2)
				if i != len(temp) - 1:
					ans.append(1)
		print(len(ans))
		print(*ans)


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

def MI():
	return map(int, sys.stdin.buffer.readline().split())

def LI():
	return list(map(int, sys.stdin.buffer.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()
inf = 10 ** 16
md = 10 ** 9 + 7
for _ in range(II()):
	k = II()
	if k & 1:
		print(-1)
		continue
	ans = []
	two = 1 << 62
	c0 = 60
	while k:
		if k >= two - 2:
			ans += [1] + [0] * c0
			k -= two - 2
		else:
			two >>= 1
			c0 -= 1
	print(len(ans))
	print(*ans)


import sys
import math, bisect, operator
(inf, m) = (float('inf'), 10 ** 9 + 7)
sys.setrecursionlimit(10 ** 6)
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, defaultdict
I = lambda : int(sys.stdin.readline())
neo = lambda : map(int, sys.stdin.readline().split())
Neo = lambda : list(map(int, sys.stdin.readline().split()))
for _ in range(I()):
	n = I()
	Ans = '1'
	n -= 2
	if n % 2:
		print(-1)
		continue
	t = 0
	p = 2
	while t != n:
		if t + 2 ** p <= n:
			t += 2 ** p
			p += 1
			Ans += '0'
		else:
			t += 2
			Ans += '1'
			p = 2
	if len(Ans) > 2000:
		print(-1)
		continue
	print(len(Ans))
	print(*list(Ans))


import sys
input = sys.stdin.readline

def f(x):
	for i in range(64, -1, -1):
		if (1 << i) - 1 <= x:
			return i

def ok(x):
	l = []
	while x > 0:
		y = f(x)
		l.append(y)
		x -= (1 << y) - 1
	return l
t = int(input())
for you in range(t):
	k = int(input())
	if k % 2:
		print(-1)
		continue
	k = k // 2
	z = ok(k)
	print(sum(z))
	for i in z:
		print(1, end=' ')
		for j in range(i - 1):
			print(0, end=' ')
	print()


import sys
from array import array
import typing as Tp

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def output(*args):
	sys.stdout.buffer.write(('\n'.join(map(str, args)) + '\n').encode('utf-8'))

def main():
	t = int(input())
	ans_a = ['-1'] * t
	dp = [2]
	while dp[-1] < 10 ** 18:
		dp.append((dp[-1] + 1) * 2)
	m = len(dp)
	for ti in range(t):
		n = int(input())
		if n & 1:
			continue
		a = []
		stage = 0
		for i in range(m - 1, -1, -1):
			stage += n // dp[i] * (i + 1)
			if stage > 2000:
				break
			a.extend(([1] + [0] * i) * (n // dp[i]))
			n %= dp[i]
		else:
			ans_a[ti] = f"{stage}\n{' '.join(map(str, a))}"
	output('\n'.join(map(str, ans_a)))
main()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	ans = []
	if n & 1:
		print(-1)
		continue
	while n > 0:
		num = 1
		n -= 2
		while n > 2 ** (num + 1):
			num += 1
			n -= 2 ** num
		ans.append(num)
	total = 0
	for i in range(len(ans)):
		total += ans[i]
	print(total)
	for i in range(len(ans)):
		print(1, end=' ')
		for j in range(ans[i] - 1):
			print(0, end=' ')
	print()


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
from itertools import permutations, combinations

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from decimal import Decimal
sys.setrecursionlimit(100000)
INF = float('inf')
mod = 10 ** 9 + 7
for t in range(int(data())):
	k = int(data())
	if k % 2:
		out(-1)
	else:
		ans = []
		while k:
			a = 2
			cnt = 1
			while a * 2 + 2 <= k:
				a = a * 2 + 2
				cnt += 1
			ans += [1] + [0] * (cnt - 1)
			k -= a
		out(len(ans))
		outl(ans)