At the children's day, the child came to Picks's house, and messed his house up. Picks was angry at him. A lot of important things were lost, in particular the favorite set of Picks.

Fortunately, Picks remembers something about his set S:  its elements were distinct integers from 1 to limit;  the value of $\sum_{x \in S} \text{lowbit}(x)$ was equal to sum; here lowbit(x) equals 2^{k} where k is the position of the first one in the binary representation of x. For example, lowbit(10010_2) = 10_2, lowbit(10001_2) = 1_2, lowbit(10000_2) = 10000_2 (binary representation). 

Can you help Picks and find any set S, that satisfies all the above conditions?


-----Input-----

The first line contains two integers: sum, limit (1 ≤ sum, limit ≤ 10^5).


-----Output-----

In the first line print an integer n (1 ≤ n ≤ 10^5), denoting the size of S. Then print the elements of set S in any order. If there are multiple answers, print any of them.

If it's impossible to find a suitable set, print -1.


-----Examples-----
Input
5 5

Output
2
4 5

Input
4 3

Output
3
2 3 1

Input
5 1

Output
-1



-----Note-----

In sample test 1: lowbit(4) = 4, lowbit(5) = 1, 4 + 1 = 5.

In sample test 2: lowbit(1) = 1, lowbit(2) = 2, lowbit(3) = 1, 1 + 2 + 1 = 4.

Source: codeforces | Difficulty: MEDIUM
Tags: Bit manipulation

Sorting

Implementation

Greedy algorithms


Solutions:
def findOrder(limit):
	order = 0
	while limit > 1:
		limit = limit >> 1
		order += 1
	return order

def findLimit(num, limit):
	order = findOrder(limit)
	ans = []
	while num != 0:
		if order == -1:
			return [-1]
		multiplier = 1
		base = 2 ** order
		curNum = base * multiplier
		while curNum <= limit and base <= num:
			ans.append(curNum)
			num -= base
			multiplier += 2
			curNum = base * multiplier
		order -= 1
	return ans

def printAnswer(lst):
	if lst[0] == -1:
		print(-1)
	else:
		print(len(lst))
		for i in lst:
			print(i, end=' ')
(sm, lmt) = map(int, input().split(' '))
printAnswer(findLimit(sm, lmt))


(s, limit) = map(int, input().split())
Cnt = [[]]
for i in range(10 ** 5):
	Cnt.append([])
Ind = [0] * (10 ** 5 + 1)
m = 0
for i in range(1, limit + 1):
	pos = 0
	x = i
	while x % 2 == 0:
		x //= 2
		pos += 1
	Cnt[2 ** pos].append(i)
	m = max(m, 2 ** pos)
L = []
while s > 0:
	e = s
	for j in range(min(m, s), -1, -1):
		if Ind[j] < len(Cnt[j]):
			L.append(Cnt[j][Ind[j]])
			Ind[j] += 1
			s -= j
			m = min(m, j)
			break
	if s == e:
		print(-1)
		break
if s == 0:
	print(len(L))
	for item in L:
		print(item, end=' ')


import logging
import copy
import sys
import math
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)

def solve(total, limit):
	last_bit = 0
	bits = []
	while limit > 0:
		bit = limit & 1
		last_bit += 1
		limit >>= 1
		n = limit if bit == 0 else limit + 1
		bits.append(n)
	bits[-1] = 1
	bit_list = []
	for i in range(len(bits) - 1, -1, -1):
		base = int(math.pow(2, i))
		n = bits[i]
		used = 0
		while total > 0 and total >= base and (used < n):
			total -= base
			used += 1
		bit_list.append(used)
	bit_list.reverse()
	result = []
	for (i, n) in enumerate(bit_list):
		base = int(math.pow(2, i))
		for j in range(0, n):
			mask = j << i + 1
			result.append(base | mask)
	if total > 0:
		print(-1)
		return
	print(len(result))
	print(' '.join(list(map(lambda x: str(x), result))))

def main():
	firstLine = input().split()
	solve(int(firstLine[0]), int(firstLine[1]))

def log(*message):
	logging.debug(message)
main()


table = [0] * 17

def maxsum(x):
	b = bin(x)[2:]
	ans = 0
	for (i, v) in enumerate(reversed(b)):
		if v == '1':
			table[i] += 1
			for n in range(i):
				table[n] += 2 ** (i - n - 1)
	for (i, v) in enumerate(table):
		ans += 2 ** i * v
	return ans

def lowbit(x):
	b = bin(x)[2:]
	for (i, v) in enumerate(reversed(b)):
		if v == '1':
			return 2 ** i
(s, l) = [int(x) for x in input().split()]
candi = []
mm = maxsum(l)
if s > mm:
	print('-1')
else:
	flag = True
	while s:
		for i in reversed(range(len(table))):
			if table[i] > 0 and 2 ** i <= s:
				s -= 2 ** i
				table[i] -= 1
				candi.append(table[i] * 2 ** (i + 1) + 2 ** i)
				break
		else:
			flag = False
			break
	if flag:
		print(len(candi))
		for x in candi:
			print(x, end=' ')
		print()
	else:
		print('-1')


(summ, lim) = map(int, input().split())
c = 0
ans = []
for i in range(lim, 0, -1):
	c = i ^ i & i - 1
	if c <= summ:
		ans.append(i)
		summ -= c
if summ != 0:
	print(-1)
else:
	print(len(ans))
	print(*ans)


from collections import defaultdict
mp = defaultdict(list)
(sm, limit) = map(int, input().split())
ts = 0
v = set()
for i in range(1, limit + 1):
	for j in range(32):
		if i & 1 << j != 0:
			mp[1 << j].append(i)
			v.add(1 << j)
			ts += 1 << j
			break
ans = []
if sm > ts:
	print(-1)
else:
	v = list(v)
	v.sort(reverse=True)
	for i in v:
		for j in mp[i]:
			if sm >= i:
				sm -= i
				ans.append(j)
			else:
				break
	print(len(ans))
	print(*ans)


from bisect import *
import math
from collections import *
from heapq import *
from itertools import *
inf = 10 ** 18
mod = 10 ** 9 + 7
(n, m) = map(int, input().split())
ones = 0
arr = []
for i in range(1, m + 1):
	j = i
	if i % 2:
		ones += 1
	else:
		cnt = 0
		while i & 1 == 0:
			cnt += 1
			i >>= 1
		arr.append((j, pow(2, cnt)))
ans = []
for i in range(len(arr) - 1, -1, -1):
	if arr[i][1] <= n:
		ans.append(arr[i][0])
		n -= arr[i][1]
if n - ones <= 0:
	diff = n
	for i in range(1, m + 1, 2):
		if diff == 0:
			break
		diff -= 1
		ans.append(i)
	print(len(ans))
	print(*ans)
else:
	print(-1)


(a, b) = [int(x) for x in input().split()]
arr = []
for i in range(b, 0, -1):
	curr = i
	c = 0
	while curr & 1 == 0:
		c += 1
		curr = curr >> 1
	if 2 ** c <= a:
		a -= 2 ** c
		arr.append(i)
if a == 0:
	print(len(arr))
	print(*arr)
else:
	print(-1)


(sum, limit) = map(int, input().split())
ans = []
for i in range(limit, 0, -1):
	n = i & -i
	if n <= sum:
		sum -= n
		ans.append(i)
if sum == 0:
	print(len(ans))
	for i in ans:
		print(i, end=' ')
else:
	print(-1)


(sum, lim) = list(map(int, input().split()))
a = []
while lim > 0 and sum > 0:
	if lim & -lim <= sum:
		sum = sum - (lim & -lim)
		a.append(lim)
	lim = lim - 1
if sum > 0:
	print(-1)
else:
	print(len(a))
	for i in range(len(a)):
		print(a[i], end=' ')


def lowbit(x):
	i = 0
	while x & 1 == 0:
		x >>= 1
		i += 1
	return 1 << i

def main():
	(Sum, limit) = [int(i) for i in input().split()]
	d = {}
	for i in range(1, limit + 1):
		tmp = lowbit(i)
		if tmp not in d:
			d[tmp] = []
		d[tmp].append(i)
	result = []
	i = Sum
	while i > 0 and Sum:
		if i in d and d[i]:
			result.append(d[i].pop())
			Sum -= i
			i = min(Sum, i)
		else:
			i -= 1
	if Sum:
		print('-1')
	else:
		print(len(result))
		for i in result:
			print(i, end=' ')
main()


def main():
	(n, m) = map(int, input().split())
	step = 1 << m.bit_length() - 1
	m += 1
	l = [True] * m
	while step:
		if n >= step:
			for i in range(step, m, step):
				if l[i]:
					if n >= step:
						l[i] = False
						n -= step
						if not n:
							l = [j for (j, f) in enumerate(l) if not f]
							print(len(l))
							print(' '.join(map(str, l)))
							return
					else:
						break
		step //= 2
	print(-1)
main()


(s, l) = map(int, input().split())
ct_limit = {i: [] for i in range(19)}
for i in range(1, l + 1):
	cp = i
	ct = 0
	while i:
		if i & 1:
			ct_limit[ct].append(cp)
			break
		ct += 1
		i >>= 1
if sum((2 ** k * len(v) for (k, v) in ct_limit.items())) < s:
	print(-1)
else:
	ans = []
	ct = 0
	for i in range(18, -1, -1):
		sh = 0
		while sh < len(ct_limit[i]) and s >= 2 ** i:
			ans.append(ct_limit[i][sh])
			sh += 1
			s -= 2 ** i
	if s != 0:
		print(-1)
	else:
		print(len(ans))
		print(*ans)


(s, l) = map(int, input().split())
r = []
while l > 0 and s > 0:
	if s - (l & l) >= 0:
		s -= l & -l
		r.append(l)
	l -= 1
if s != 0:
	print(-1)
else:
	print(len(r))
	print(*r)


(n, l) = map(int, input().split())
i = 1
while 2 * i < n:
	i *= 2
res = []
while n and i:
	for j in range(i, l + 1, 2 * i):
		if i > n:
			break
		else:
			res.append(j)
			n -= i
	i //= 2
if n == 0:
	print(len(res))
	print(*res)
else:
	print(-1)


import math
import sys
import collections
import bisect
import string

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

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

def get_string():
	return sys.stdin.readline().strip()
for t in range(1):
	(s, l) = get_ints()
	ans = dict()
	for i in range(1, l + 1):
		val = i
		c = 0
		while val & 1 != 1:
			val >>= 1
			c += 1
		number = 2 ** c
		if number not in ans:
			ans[number] = [i]
		else:
			ans[number].append(i)
	key = list(ans.keys())
	key.sort(reverse=True)
	sol = []
	for i in key:
		val = min(len(ans[i]), s // i)
		for j in range(val):
			sol.append(ans[i][j])
		s -= val * i
	if s == 0:
		print(len(sol))
		print(*sol)
	else:
		print(-1)


(s, l) = map(int, input().split())
lis = []
t = 2
count = l
while True:
	if l // t != 0:
		lis.append(l // t)
		count += l // t * t // 2
		t = t * 2
	else:
		break
if count < s:
	print(-1)
else:
	count = 0
	t = 2 ** len(lis)
	a = 2 ** len(lis)
	k = t
	lis = []
	while t > 1:
		if count + t <= s and k <= l:
			count += t
			lis.append(k)
			if t == a:
				k += t
			else:
				k += 2 * t
		else:
			t = t // 2
			k = t
	for i in range(1, l + 1, 2):
		if count == s:
			break
		count += 1
		lis.append(i)
	print(len(lis))
	print(*lis)


from math import log2

def solve(s, limit):
	res = []
	bit_length = int(log2(limit))
	for i in range(bit_length, -1, -1):
		low_bit = 2 ** i
		for j in range(1, limit + 1, 2):
			t = low_bit * j
			if low_bit > s or t > limit:
				break
			s -= low_bit
			res.append(t)
	return res if s == 0 else None
res = solve(*list(map(int, input().split())))
if res is None:
	print(-1)
else:
	print(len(res))
	print(' '.join((str(x) for x in res)))


(target, limit) = list(map(int, input().split()))

def lowbit(x):
	return x & (x ^ x - 1)
ans = []
for i in range(limit, 0, -1):
	x = lowbit(i)
	if x <= target:
		ans.append(i)
		target -= x
if target:
	print(-1)
else:
	print(len(ans))
	print(' '.join(map(str, ans)))


def lowbit(n):
	binary_n = bin(n).replace('0b', '')
	last_1 = 0
	for (i, v) in enumerate(binary_n[::-1]):
		if v == '1':
			last_1 = len(binary_n) - i - 1
			break
	lowbit_n = binary_n[last_1:]
	return int(lowbit_n, 2)
(summ, limit) = list(map(int, input().split()))
ans = []
for i in range(limit, 0, -1):
	if i % 2 == 0 and summ > 0:
		if lowbit(i) <= summ:
			ans.append(i)
			summ -= lowbit(i)
for i in range(1, limit + 1):
	if i % 2 != 0 and summ > 0:
		ans.append(i)
		summ -= 1
if summ == 0:
	print(len(ans))
	print(*ans)
else:
	print(-1)


(sum, lim) = map(int, input().split())
arr = []
now = 0
for i in range(lim, -1, -1):
	if now + (i & -i) <= sum:
		now += i & -i
		arr.append(i)
if now != sum:
	print(-1)
else:
	print(len(arr) - 1)
	for i in range(0, len(arr) - 1):
		print(arr[i])


(s, l) = map(int, input().split())
list1 = []
for i in range(1, l + 1):
	list1.append((i & -i, i))
list1.sort(reverse=True)
ll = []
for i in range(l):
	if list1[i][0] <= s:
		ll.append(list1[i][1])
		s -= list1[i][0]
if s == 0:
	print(len(ll))
	print(*ll)
else:
	print(-1)


class IOHandlerObject(object):

	def getInput(self, mode=2):
		inputs = input().strip()
		if mode == 0:
			return inputs
		if mode == 1:
			return inputs.split()
		if mode == 2:
			return [int(x) for x in inputs.split()]

	def writeOutput(self, s='\n'):
		if isinstance(s, list):
			s = ' '.join(s)
		print(s)
IOHandler = IOHandlerObject()
g = IOHandler.getInput
w = IOHandler.writeOutput
(s, l) = g()
res = []
i = 16
while i + 1:
	c = 1
	while True:
		if 2 ** i * c > l:
			break
		if 2 ** i > s:
			break
		res.append(2 ** i * c)
		c += 2
		s -= 2 ** i
	i -= 1
if s:
	print(-1)
else:
	print(len(res))
	print(' '.join((str(x) for x in res)))


(Sum, limit) = map(int, input().split())
res = []
choose = []
for i in range(1, limit + 1):
	choose.append((i & -i, i))
choose.sort()
for (i, j) in choose[::-1]:
	if i <= Sum:
		Sum -= i
		res.append(j)
if Sum:
	print('-1')
else:
	print(len(res))
	print(*res)


(n, m) = map(int, input().split())
d = {}
temp = []
for i in range(1, m + 1):
	lb = i & -i
	if lb not in d:
		d[lb] = []
	d[lb].append(i)
	temp.append(lb)
temp = sorted(temp)[::-1]
ans = []
for j in temp:
	if j <= n and len(d[j]):
		n -= j
		ans.append(d[j][-1])
		d[j].pop()
if n == 0:
	print(len(ans))
	print(*ans)
else:
	print(-1)


import sys
import string
import math
from collections import defaultdict
from functools import lru_cache
from collections import Counter
from fractions import Fraction

def mi(s):
	return map(int, s.strip().split())

def lmi(s):
	return list(mi(s))

def tmi(s):
	return tuple(mi(s))

def mf(f, s):
	return map(f, s)

def lmf(f, s):
	return list(mf(f, s))

def js(lst):
	return ' '.join((str(d) for d in lst))

def jsns(lst):
	return ''.join((str(d) for d in lst))

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

def linesp():
	return line().split()

def iline():
	return int(line())

def mat(n):
	matr = []
	for _ in range(n):
		matr.append(linesp())
	return matr

def matns(n):
	mat = []
	for _ in range(n):
		mat.append([c for c in line()])
	return mat

def mati(n):
	mat = []
	for _ in range(n):
		mat.append(lmi(line()))
	return mat

def pmat(mat):
	for row in mat:
		print(js(row))

def main():
	(n, l) = mi(line())
	used = set()
	counts = defaultdict(list)
	for ll in range(1, l + 1):
		pos = 0
		i = ll
		while i:
			(i, curr) = (i // 2, i % 2)
			if curr == 1:
				counts[2 ** pos].append(ll)
				break
			pos += 1
	pos = 0
	while n:
		(n, curr) = (n // 2, n % 2)
		if curr:
			need = 2 ** pos
			if need in counts:
				used.add(counts[need].pop())
			else:
				required = need
				while need and required:
					if need not in counts:
						need //= 2
					elif need in counts and len(counts[need]) > 0:
						num = required // need
						for _ in range(min(num, len(counts[need]))):
							used.add(counts[need].pop())
							required -= need
					else:
						need //= 2
				if required != 0:
					print(-1)
					return
		pos += 1
	print(len(used))
	print(js(used))
main()


(s, l) = map(int, input().split())
lowbit = [0]
idx = [0]
for i in range(1, l + 1):
	x = bin(i)
	x = x[::-1]
	lowbit.append(2 ** x.index('1'))
	idx.append(i)
idx.sort(key=lambda i: lowbit[i], reverse=True)
p = 0
ans = []
while s and p < l:
	if lowbit[idx[p]] <= s:
		s -= lowbit[idx[p]]
		ans.append(idx[p])
	p += 1
if s:
	print(-1)
else:
	print(len(ans))
	print(*ans)


(som, lim) = map(int, input().split())
x = bin(som)[2:]
y = bin(lim)[2:]
import math

def git(n):
	return int(math.log2(n & -n) + 1)
d = dict()
e = dict()
for j in range(1, lim + 1):
	u = git(j)
	if u in d.keys():
		d[u] += 1
		e[u].append(j)
	else:
		d[u] = 1
		e[u] = [j]
S = []
n = len(y)
while n >= 0 and som > 0:
	if n not in e.keys():
		n -= 1
	elif len(e[n]) > 0 and som >= 2 ** (n - 1):
		som -= 2 ** (n - 1)
		S.append(e[n].pop())
	else:
		n -= 1
if som == 0:
	print(len(S))
	print(*S)
else:
	print(-1)


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2, floor, log
from bisect import bisect_right, bisect_left, bisect
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def isPowerOfTwo(x):
	return x and (not x & x - 1)
MOD = 1000000007
PMOD = 998244353
N = 100000.0 + 1
LOGN = 30
alp = 'abcdefghijklmnopqrstuvwxyz'
T = 1
for _ in range(T):
	(s, l) = list(map(int, stdin.readline().rstrip().split()))
	a = []
	for i in range(1, l + 1):
		x = bin(i)[2:].zfill(LOGN)
		lb = -1
		for j in range(LOGN - 1, -1, -1):
			if x[j] == '1':
				lb = pow(2, LOGN - j - 1)
				break
		a.append([lb, int(x, 2)])
	a.sort(reverse=True)
	ans = []
	tmp = 0
	for i in range(l):
		if s >= a[i][0]:
			s -= a[i][0]
			tmp += a[i][0]
			ans.append(a[i][1])
		if s == 0:
			break
	if s != 0:
		print(-1)
	else:
		print(len(ans))
		print(*ans)


(s, l) = map(int, input().split())
val = []
for i in range(1, l + 1):
	for b in range(17):
		if i & 1 << b:
			val.append([1 << b, i])
			break
val.sort(reverse=True)
ans = []
for i in val:
	if i[0] <= s:
		s -= i[0]
		ans.append(i[1])
if s > 0:
	print(-1)
	quit()
print(len(ans))
for i in ans:
	print(i, end=' ')


import math
(sum, limit) = map(int, input().split())
x = 0
lis = list()
for i in range(limit, 0, -1):
	if x < sum and limit > 0 and (x + (i & -i) <= sum):
		x += i & -i
		lis.append(i)
		limit -= 1
if x != sum:
	print(-1)
else:
	print(len(lis))
	for i in lis:
		print(i, '', end='')


(s, l) = map(int, input().split())
d = [-1] * (l + 1)
for i in range(1, l + 1):
	if i % 2:
		d[i] = 0
	else:
		d[i] = d[i // 2] + 1
p = sorted(list(range(1, l + 1)), key=lambda x: -d[x])
ans = []
for i in p:
	if s == 0:
		break
	elif s < 1 << d[i]:
		continue
	else:
		ans.append(i)
		s -= 1 << d[i]
if s == 0:
	print(len(ans))
	print(*ans)
else:
	print(-1)


(s, n) = list(map(int, input().split()))
y = []
y1 = []
sum1 = 0
for i in range(1, n + 1):
	power = 0
	de = i
	while i % 2 == 0:
		power += 1
		i = i // 2
	if sum1 + 2 ** power <= s:
		sum1 += 2 ** power
		y.append(de)
sum2 = 0
for i in range(n, 0, -1):
	power = 0
	de = i
	while i % 2 == 0:
		power += 1
		i = i // 2
	if sum2 + 2 ** power <= s:
		sum2 += 2 ** power
		y1.append(de)
if sum1 == s:
	print(len(y))
	print(*y)
elif sum2 == s:
	print(len(y1))
	print(*y1)
else:
	print(-1)


import sys
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

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

def si():
	return input()

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def read():
	tc = 0
	if tc:
		input = sys.stdin.readline
	else:
		sys.stdin = open('input1.txt', 'r')
		sys.stdout = open('output1.txt', 'w')

def solve():
	a = []
	for i in range(1, 100005):
		for j in range(31):
			if i & 1 << j:
				a.append(1 << j)
				break
	(n, k) = mi()
	s = sum(a[:k])
	if n > s:
		print('-1')
	else:
		a = a[:k]
		x = []
		j = 1
		for i in a:
			x.append([i, j])
			j += 1
		x.sort(reverse=True)
		ans = []
		for i in x:
			if n >= i[0]:
				ans.append(i[1])
				n -= i[0]
		if n:
			print('-1')
		else:
			print(len(ans))
			print(*ans)
solve()


(sum, limit) = map(int, input().split())
ans = []
while limit > 0 and sum > 0:
	if limit & -limit <= sum:
		sum -= limit & -limit
		ans.append(limit)
	limit -= 1
if sum > 0:
	print(-1)
else:
	print(len(ans))
	print(*ans)


from sys import stdin, stdout
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, input().split()))
p2 = [1]
for i in range(18):
	p2 += [p2[-1] * 2]
N = 10 ** 5 + 5
lb = [0]
for i in range(1, N):
	for bp in range(18):
		if i >> bp & 1:
			pos = bp
			break
	lb += [p2[pos]]
for i in range(1):
	(sm, n) = lst()
	v = n
	ans = set()
	while v > 0:
		if v <= sm:
			sm -= lb[v]
			ans.add(v)
		v -= 1
		if sm == 0:
			break
	if sm != 0:
		print(-1)
	else:
		print(len(ans))
		for v in ans:
			stdout.write(str(v) + ' ')


kk = lambda : map(int, input().split())
(su, l) = kk()
(cnts, i) = ([], 0)
while 1:
	v = l // 2 ** i
	v = v // 2 + (v & 1)
	if v == 0:
		break
	cnts.append(v)
	i += 1
c = 0
s = []
for i in range(len(cnts) - 1, -1, -1):
	v = 2 ** i
	while v <= l:
		if c + 2 ** i > su:
			break
		s.append(v)
		c += 2 ** i
		v += 2 ** (i + 1)
if c < su:
	print(-1)
else:
	print(len(s))
	print(*s)


(a, b) = map(int, input().split())
res = []
for i in range(b, 0, -1):
	k = i & (i ^ i - 1)
	if a >= k:
		res.append(str(i))
		a -= k
if a > 0:
	print(-1)
else:
	print(len(res))
	print(*res)


import math

def main():
	(sum_bits, limit) = map(int, input().split())
	nums = set()
	upper_bit = int(math.log2(limit))
	max_num = 1 << upper_bit
	while max_num > 0:
		for num in range(max_num, limit + 1, max_num << 1):
			if max_num <= sum_bits:
				nums.add(num)
				sum_bits -= max_num
			else:
				break
		if sum_bits <= 0:
			break
		max_num >>= 1
	if sum_bits != 0:
		print(-1)
	else:
		print(len(nums))
		print(' '.join(map(str, nums)))
main()


(sum, limit) = map(int, input().split(' '))
ans = set()

def low_bit(n):
	k = 0
	while not n & 1 << k:
		k += 1
	return 1 << k
for i in reversed(range(1, limit + 1)):
	t = low_bit(i)
	if sum >= t:
		sum -= t
		ans.add(i)
if sum == 0:
	print(len(ans))
	print(' '.join([str(x) for x in ans]))
else:
	print(-1)


import sys
import copy
import math

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

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

def get_string():
	return sys.stdin.readline().strip()
t = 1
for test in range(t):
	(s, l) = get_ints()
	ans = []
	for i in range(18, -1, -1):
		for k in range(1, l + 1, 2):
			if k * 2 ** i > l:
				break
			if s >= 2 ** i:
				s -= 2 ** i
				ans.append(k * 2 ** i)
			if s == 0:
				break
		if s == 0:
			break
	if s != 0:
		print(-1)
		continue
	print(len(ans))
	print(*ans)


(s, l) = map(int, input().split())
arr = [0] + [0 for i in range(l)]
dic = {}
for i in range(1, l + 1):
	x = bin(i)
	m = len(x)
	for j in range(0, m):
		if x[m - j - 1] == '1':
			arr[i] = 2 ** j
			y = 2 ** j
			if y in dic:
				dic[y].append(i)
			else:
				dic[y] = [i]
			break
f = s
arr1 = sorted(arr)
for i in range(l, 0, -1):
	if arr1[i] > f:
		arr1[i] = 0
	else:
		f += -arr1[i]
if sum(arr1) == s:
	final = True
else:
	final = False
final_arr = []
if final:
	t = 0
	for i in range(1, l + 1):
		if arr1[i] != 0:
			t += 1
			for j in range(len(dic[arr1[i]])):
				if dic[arr1[i]][j] != -1:
					final_arr.append(dic[arr1[i]][j])
					dic[arr1[i]][j] = -1
					break
	print(t)
	for i in final_arr:
		print(i, end=' ')
else:
	print(-1)


def check(num):
	x = str(bin(num))
	j = -1
	for i in range(len(x) - 1, -1, -1):
		j += 1
		if x[i] == '1':
			break
	return j
(s, limit) = [int(x) for x in input().split()]
res = []
for i in range(1, limit + 1):
	x = check(i)
	res.append([2 ** x, i])
res.sort(key=lambda x: x[0])
ans = []
for i in range(len(res) - 1, -1, -1):
	if s >= res[i][0]:
		s -= res[i][0]
		ans.append(res[i][1])
	if s == 0:
		break
if s != 0:
	print(-1)
else:
	print(len(ans))
	print(*ans, sep=' ')


(sum, limit) = [int(x) for x in input().split()]
odd = int(limit / 2)
even = odd
if limit % 2 == 1:
	odd += 1
a = []
for i in range(2, limit + 1, 2):
	c = 0
	num = i
	while i % 2 == 0:
		i /= 2
		c += 1
	a.append([int(2 ** c), int(num)])
a.sort(key=lambda x: x[0], reverse=True)
x = len(a)
s = 0
i = 0
ans = []
count = 0
while i != even and s + a[i][0] < sum:
	s += a[i][0]
	ans.append(a[i][1])
	count += 1
	i += 1
if s == sum:
	print(count)
	print(*ans)
else:
	rem = sum - s
	if odd < rem:
		print(-1)
	else:
		j = 1
		for i in range(rem):
			ans.append(j)
			j += 2
			count += 1
		print(count)
		print(*ans)


(s, l) = map(int, input().split())
t = []
for i in range(l, 0, -1):
	k = i & (i ^ i - 1)
	if s >= k:
		t.append(str(i))
		s -= k
print(-1 if s else str(len(t)) + '\n' + ' '.join(t))


(n, m) = map(int, input().split())
ans = []
maxa = 0
count = 0
from collections import defaultdict
al = defaultdict(list)
for i in range(1, m + 1):
	temp = bin(i)
	temp = temp[2:]
	temp = temp[::-1]
	flag = 0
	for j in range(len(temp)):
		if temp[j] == '1':
			al[pow(2, j)].append(i)
			count += pow(2, j)
			maxa = max(maxa, pow(2, j))
			flag = 1
		if flag == 1:
			break
ans = []
if n > count:
	print(-1)
else:
	while maxa >= 1 and n > 0:
		if n >= maxa:
			index = len(al[maxa]) - 1
			while n >= maxa and len(al[maxa]) > 0:
				ans.append(al[maxa][index])
				n -= maxa
				al[maxa].pop()
				index -= 1
		maxa = maxa // 2
	print(len(ans))
	print(*ans)


a = [0 for x in range(0, 18)]
k = [0 for x in range(0, 18)]
ss = input()
kay = ss.split(' ')
suma = int(kay[0])
limit = int(kay[1])
for i in range(16, -1, -1):
	a[i] = int(limit / pow(2, i)) - int(limit / pow(2, i + 1))
for i in range(16, -1, -1):
	while suma >= pow(2, i) and a[i] > 0:
		suma = suma - pow(2, i)
		a[i] = a[i] - 1
		k[i] = k[i] + 1
les = ''
N = sum(k)
if suma != 0:
	print(-1)
else:
	print(N)
	for i in range(0, 17):
		j = 0
		while k[i] != 0:
			les = les + str(pow(2, i) * (2 * j + 1)) + ' '
			k[i] = k[i] - 1
			j = j + 1
print(les)


import math
(a, b) = map(int, input().split())
l = []
s = 0
c = 0

def ffs(n):
	return math.log2(n & -n) + 1
for i in range(b, 0, -1):
	d = ffs(i)
	ad = 2 ** (d - 1)
	if s + ad <= a:
		l.append(i)
		s = s + ad
		c = c + 1
if s == a:
	print(c)
	print(*l)
else:
	print('-1')


(sum1, limit) = map(int, input().split())
cou = 0
cnt = 0
visited = list()
num = list()
norm = list()
for i in range(1, limit + 1):
	if i % 2 == 1:
		num.append((i, 1))
	else:
		binary = bin(i).replace('0b', '')
		index = 0
		for j in range(len(binary)):
			if binary[j] == '1':
				index = j
		binary = binary[index:]
		num.append((i, int(binary, 2)))
num = sorted(num, key=lambda x: x[1], reverse=True)
for i in range(len(num)):
	if num[i][1] + cou <= sum1:
		cou += num[i][1]
		visited.append(num[i][0])
		cnt += 1
if cou == sum1:
	print(cnt)
	print(*visited)
else:
	print(-1)


while True:
	try:

		def solution(s, l):
			ans = list()
			i = l
			idn = t = 1
			while i >= 1:
				tr = i & t
				if tr > 0 and t <= s:
					s -= t
					ans.append(i)
					(t, i) = (1, i - 1)
				elif tr > 0 and t > s:
					i -= 1
					t = 1
				else:
					t *= 2
				if s == 0:
					break
			if s == 0:
				print(len(ans))
				print(*ans)
			else:
				print(-1)

		def read():
			(sum, limit) = map(int, input().split())
			solution(sum, limit)
		if __name__ == '__main__':
			read()
	except EOFError:
		break


import math

def lowbit(x):
	b = bin(x)
	b = b[::-1]
	return 2 ** b.index('1')
(s, limit) = map(int, input().split())
arr = []
_sum = 0
a = []
for i in range(1, limit + 1):
	l = lowbit(i)
	arr.append([i, l])
	a.append(i)
	_sum += l
if _sum < s:
	print(-1)
elif _sum == s:
	print(limit)
	print(*a)
else:
	arr.sort(reverse=True, key=lambda x: x[1])
	ans = []
	te = 0
	for i in range(len(arr)):
		te += arr[i][1]
		ans.append(arr[i][0])
		if te == s:
			break
		elif te > s:
			te -= arr[i][1]
			ans.remove(arr[i][0])
	print(len(ans))
	print(*ans)


(x, y) = map(int, input().split())
a = []
for i in range(y, 0, -1):
	s = i & (i ^ i - 1)
	if x >= s:
		x -= s
		a.append(i)
if x > 0:
	print(-1)
else:
	print(str(len(a)))
	print(*a)


(b, a) = map(int, input().split())
l = sorted(((i & -i, i) for i in range(1, a + 1)))
res = []
for (x, e) in l[::-1]:
	if b == 0:
		break
	if x <= b:
		b -= x
		res.append(e)
if b:
	print(-1)
else:
	print(len(res))
	print(*res)


import sys
import bisect
import heapq
from math import *
from collections import defaultdict as dd
from collections import deque
from collections import Counter as c
from itertools import combinations as comb
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

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

def out(var):
	sys.stdout.write(var)

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

def sl():
	return list(map(str, data().split()))

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]

def lower_two(n):
	i = 17
	answer = 1
	while i >= 0:
		answer = max(answer, gcd(int(pow(2, i)), n))
		i -= 1
	return answer
(s, limit) = sp()
dp = dict()
for i in range(1, limit + 1):
	dp[i] = lower_two(i)
prefix = sum(dp.values())
dp = sorted(dp.items(), key=lambda x: x[1])
if s > prefix:
	out('-1')
	exit(0)
answer = []
for i in range(len(dp) - 1, -1, -1):
	if dp[i][1] <= s:
		answer.append(dp[i][0])
		s -= dp[i][1]
	if s == 0:
		break
out(str(len(answer)) + '\n')
for i in answer:
	out(str(i) + ' ')
exit()


def main():
	(s, l) = map(int, input().split())
	a = []
	for i in range(l, 0, -1):
		k = i & -i
		if s - k < 0:
			continue
		s -= k
		a.append(i)
	if s > 0:
		print(-1)
	else:
		print(len(a))
		print(*a)
	return
main()


from sys import stdin
from itertools import combinations
import sys
import math
from collections import defaultdict
sys.setrecursionlimit(15000)
(s, limit) = list(map(int, stdin.readline().split()))
mydict = defaultdict(list)
bit = [0] * 17
for i in range(1, limit + 1):
	for j in range(0, 17):
		if i & 2 ** j == 2 ** j:
			bit[j] += 1
			mydict[j].append(i)
			break
myset = set()
i = 16
while i >= 0 and s > 0:
	if 2 ** i <= s and bit[i] > 0:
		bit[i] -= 1
		s -= 2 ** i
		myset.add(mydict[i].pop())
	else:
		i -= 1
if s == 0:
	print(len(myset))
	print(*list(myset))
else:
	print(-1)


(s, l) = map(int, input().split())
c = []
for i in range(1, 100001):
	if i % 2 != 0:
		c.append([1, i])
	else:
		k = list(bin(i))
		k.reverse()
		z = k.index('1')
		c.append([pow(2, z), i])
c = sorted(c)
c.reverse()
z = []
for i in range(len(c)):
	if s == 0:
		break
	elif s >= c[i][0] and c[i][1] <= l:
		s -= c[i][0]
		if s < 0:
			s += c[i][0]
		else:
			z.append(c[i][1])
if s != 0:
	print(-1)
else:
	print(len(z))
	print(*z)


(s, l) = map(int, input().split())
b = list([int(x) for x in bin(min(s, l))[2:]])
i = 0
ans = []
while s > 0 and i < len(b):
	k = len(b) - i - 1
	a = 2 ** (len(b) - 1 - k)
	n = 2 ** k
	while n <= l and s >= 2 ** k and (a > 0):
		s -= 2 ** k
		a -= 1
		ans.append(str(n))
		n += 2 ** (k + 1)
	i += 1
if s != 0:
	print(-1)
else:
	print(len(ans))
	print(' '.join(ans))


(s, limit) = map(int, input().split())
ans = []
for i in range(limit, 0, -1):
	if s - (i & -i) >= 0:
		ans.append(i)
		s -= i & -i
if s == 0:
	print(len(ans))
	print(' '.join(map(str, ans)))
else:
	print(-1)


def lowbit(n):
	f = 1
	while n & f == 0:
		f <<= 1
	return (f, n)
(s, lim) = map(int, input().split())
ans = {*range(1, lim + 1)}
bits = sorted(map(lowbit, ans), reverse=1)
cs = 0
if sum((i[0] for i in bits)) < s:
	exit(print(-1))
ans = []
i = 0
while s > 0:
	while bits[i][0] > s:
		i += 1
	ans.append(bits[i][1])
	s -= bits[i][0]
	i += 1
print(len(ans))
print(*ans)


(s, l) = map(int, input().split())
lis = [list() for _ in range(100001)]
for i in range(1, l + 1):
	lis[i & ~(i - 1)].append(i)
num = int(pow(2, s.bit_length() - 1))
invalid = 1
ans = list()
while num:
	if num & s:
		temp = num
		length = 1
		while temp:
			while len(lis[temp]):
				if length == 0:
					break
				ans.append(lis[temp].pop())
				length -= 1
			length = length << 1
			temp >>= 1
		if length:
			invalid = 0
	num >>= 1
if invalid:
	print(len(ans))
	for var in ans:
		print(var, end=' ')
else:
	print(-1)


(s, l) = map(int, input().split())
x = []
for i in range(1, l + 1):
	x.append((i & -i, i))
ss = sum([x[i][0] for i in range(len(x))])
if ss < s:
	print(-1)
else:
	x = sorted(x, reverse=True)
	xx = 0
	res = []
	rc = 0
	for i in range(len(x)):
		if xx + x[i][0] <= s:
			xx += x[i][0]
			res.append(x[i][1])
			rc += 1
	if xx == s:
		print(rc)
		for i in range(rc):
			print(res[i], end=' ')
	else:
		print(-1)


(sum, limit) = map(int, input().split())
lv = []
res = []
for i in range(1, limit + 1):
	j = 0
	while i & 1 << j == 0:
		j += 1
	lv.append([2 ** j, i])
lv.sort()
i = limit - 1
while i >= 0 and sum > 0:
	if sum - lv[i][0] >= 0:
		sum -= lv[i][0]
		res.append(i)
	i -= 1
if sum > 0:
	print(-1)
else:
	print(len(res))
	print(' '.join([str(lv[i][1]) for i in res]))


(S, L) = map(int, input().split())
(d, r) = ({}, {})
k = 0
while L >= 2 ** k:
	d[2 ** k] = (L + 2 ** k) // 2 ** (k + 1)
	k += 1
for i in sorted(d.keys())[::-1]:
	while i <= S and d[i]:
		S -= i
		d[i] -= 1
		r[i] = r.get(i, 0) + 1
ans = []
for i in sorted(r.keys())[::-1]:
	for j in range(d[i] + r[i] - 1, d[i] - 1, -1):
		ans += [str((2 * j + 1) * i)]
if S:
	print(-1)
else:
	print(len(ans))
	print(' '.join(ans))


(sum, limit) = map(int, input().split())
l = []
for i in range(limit, 0, -1):
	c = bin(i)[2:]
	c = c[::-1]
	index = c.index('1')
	if sum - 2 ** index >= 0:
		sum = sum - 2 ** index
		l.append(i)
	if sum == 0:
		break
if sum == 0:
	print(len(l))
	print(*l)
else:
	print(-1)


def main():
	(_sum, limit) = map(int, input().split())
	cur_sum = 0
	cur_div = limit
	ans = []
	while cur_sum <= _sum and cur_div >= 1:
		bin_div = bin(cur_div)[2:]
		lowest1 = bin_div.rfind('1')
		contr = 2 ** (len(bin_div) - lowest1 - 1)
		assert contr == cur_div & -cur_div
		if cur_sum + contr <= _sum:
			cur_sum += contr
			ans.append(cur_div)
		cur_div -= 1
	if cur_sum == _sum:
		print(len(ans))
		print(*ans)
	else:
		print(-1)
main()


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)

def in_int():
	return int(input())

def in_list():
	return list(map(int, input().split()))

def in_str():
	s = input()
	return list(s[:len(s) - 1])

def in_ints():
	return map(int, input().split())
(total, n) = in_ints()
l = [i for i in range(1, n + 1)]
l = sorted(l, key=lambda l: l & -l)
l = l[::-1]
ans = []
for xx in l:
	tt = xx & -xx
	if total >= tt:
		total -= tt
		ans.append(xx)
if total == 0:
	print(len(ans))
	for xx in ans:
		print(xx, end=' ')
else:
	print(-1)


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
I = sys.stdin.readline

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def main():
	(n, l) = mi()
	arr = []
	d = defaultdict(list)
	for i in range(1, l + 1):
		if i % 2:
			d[1].append(i)
			arr.append(1)
		else:
			x = bin(i)[2:][::-1]
			k = 0
			while 1:
				if x[k] == '1':
					break
				k += 1
			d[2 ** k].append(i)
			arr.append(2 ** k)
	arr.sort(reverse=True)
	x = 0
	ans = []
	for i in arr:
		if x + i <= n:
			x += i
			ans.append(d[i][-1])
			d[i].pop()
			if x == n:
				break
	if x == n:
		print(len(ans))
		print(*ans)
	else:
		print(-1)
main()


import sys
input = sys.stdin.readline

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

def array_print(arr):
	print(' '.join(map(str, arr)))
(sum, n) = multi_input()
a = [0] * (n + 1)
for i in range(1, n + 1):
	if i % 2 != 0:
		a[i] = 1
	else:
		a[i] = 2 * a[i // 2]
b = []
new_sum = flag = 0
for j in reversed(range(1, n + 1)):
	if new_sum + a[j] <= sum:
		new_sum += a[j]
		b.append(j)
		if new_sum == sum:
			flag = 1
			break
if flag == 0:
	print(-1)
else:
	print(len(b))
	array_print(b)


(s, l) = map(int, input().split())
a = []
for i in range(l, 0, -1):
	n = i & -i
	if n <= s:
		s = s - n
		a.append(i)
if s == 0:
	print(len(a))
	for i in a:
		print(i, end=' ')
else:
	print(-1)


def lowbit(x):
	return x & -x

def solve():
	global sum, limit, list
	while limit > 0 and sum != 0:
		if sum - lowbit(limit) >= 0:
			sum -= lowbit(limit)
			list.add(limit)
		limit -= 1
	if sum == 0:
		return True
	return False
(sum, limit) = tuple((int(i) for i in input().split()))
list = set()
if solve():
	s = str(len(list)) + '\n'
	for i in list:
		s += str(i) + ' '
	print(s[:len(s) - 1])
else:
	print(-1)


(h, m) = list(map(int, input().split()))
k = []
while m > 0:
	if h - m ^ m & m - 1 >= 0:
		h -= m ^ m & m - 1
		k.append(m)
	m -= 1
if h > 0:
	print(-1)
else:
	print(len(k))
	print(*k)


__author__ = 'asmn'
(s, l) = tuple(map(int, input().split(' ')))
t = 1
while t << 1 <= s:
	t <<= 1
ans = []
while s > 0 and t > 0:
	n = min((l // t + 1) // 2, s // t)
	s -= t * n
	for i in range(n):
		ans.append((i * 2 + 1) * t)
	t >>= 1
if s > 0:
	print(-1)
else:
	print(len(ans))
	print(*tuple(ans))


def main():
	(s, lm) = map(int, input().split())
	c = {}
	for i in range(1, lm + 1):
		if i & -i not in c:
			c[i & -i] = 1
		else:
			c[i & -i] += 1
	p = list(c.keys())
	p.sort(reverse=True)
	used = {k: 0 for k in p}
	total = 0
	for k in p:
		count = 0
		if s >= k and count < c[k]:
			while s >= k and count < c[k]:
				count += 1
				s -= k
			used[k] = count
			total += count
	if s > 0:
		print(-1)
	else:
		print(total)
		ans = []
		for i in range(1, lm + 1):
			if used[i & -i] > 0:
				ans.append(i)
				used[i & -i] -= 1
		print(*ans)
main()


def low(n):
	x = str(bin(n))[2:]
	x = x[::-1]
	t = x.index('1')
	temp = x[:t + 1][::-1]
	return int(temp, 2)

def child_set(s, limit):
	lst = [[i, low(i)] for i in range(1, limit + 1)]
	lst = [[0, 0]] + lst
	lst = sorted(lst, reverse=True, key=lambda s: s[1])
	i = 0
	ans = []
	while s and lst and (i < len(lst)):
		if lst[i][1] <= s:
			s -= lst[i][1]
			ans.append(lst[i][0])
			lst.pop(i)
		else:
			i += 1
	if s:
		return -1
	else:
		print(len(ans))
		print(*ans)
		return ''
(a, b) = map(int, input().strip().split())
print(child_set(a, b))


from math import log
li = [[] for i in range(10 ** 5)]
(s, l) = map(int, input().split())
temp = 0
for i in range(1, l + 1):
	x = i & -i
	li[x].append(i)
	temp += x
if temp < s:
	print(-1)
else:
	x = int(log(s, 2))
	z = 1 << x
	ans = []
	while True:
		if z <= s:
			if li[z] != []:
				ans.append(li[z].pop())
				s -= z
				if s <= 0:
					break
			else:
				z = z // 2
		else:
			z = z // 2
	print(len(ans))
	print(*ans)


def lowval(i):
	global low
	return low[i]
(s, lim) = list(map(int, input().split()))
low = [0]
result = []
(m, pm) = (1, 1)
while len(low) - 1 < lim:
	pm = len(low) - 1
	low += low[1:len(low) - 1] + [m]
	m *= 2
else:
	if len(low) - 1 == lim:
		pm = len(low) - 1
d = list(range(lim + 1))
x = sorted(d, key=lowval)
x2 = list(map(lowval, x))
for i in range(lim, 0, -1):
	if x2[i] <= s:
		result.append(x[i])
		s -= x2[i]
	if s == 0:
		break
if s != 0:
	print(-1)
else:
	print(len(result))
	for i in result:
		print(i, end=' ')
	print()


((a, b), x, y) = (list(map(int, input().split())), [], 0)

def bin(s):
	return str(s) if s <= 1 else bin(s >> 1) + str(s & 1)

def lowbit(s):
	return int('1' + bin(s).split('1')[-1], 2)
for i in reversed(range(b + 1)):
	if y == a:
		break
	if a >= y + lowbit(i):
		x.append(i)
		y += lowbit(i)
if y == a:
	print(len(x))
	print(' '.join((str(i) for i in x)))
else:
	print(-1)


import os
import sys
from io import BytesIO, IOBase

def lbit(x):
	return x & -x

def main():
	(n, s) = map(int, input().split(' '))
	ans = []
	for x in range(s, 0, -1):
		if n - lbit(x) >= 0:
			ans.append(x)
			n = n - lbit(x)
	if n == 0:
		print(len(ans))
		print(*ans)
	else:
		print(-1)
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 lowbit(x):
	return x & -x
(s, l) = map(int, input().split())
lst = []
while s > 0 and l > 0:
	if s - l >= 0:
		s -= lowbit(l)
		lst.append(l)
	l -= 1
if s != 0:
	print(-1)
else:
	print(len(lst))
	print(*lst)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
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 value():
	return tuple(map(int, input().split()))

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

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(n, limit) = value()
rightBit = []
for i in range(1, limit + 1):
	k = int(log2(i & -i))
	rightBit.append((2 ** k, i))
rightBit = rightBit[::-1]
ans = []
for (bit, num) in rightBit:
	if n - bit >= 0:
		n -= bit
		ans.append(num)
if n != 0:
	print(-1)
else:
	print(len(ans))
	print(*ans)


import math
(s, l) = map(int, input().split())
(ans, size) = (0, 0)
my_list = []
for i in range(l, 0, -1):
	k = math.log2(i & -i)
	num = 2 ** k
	if ans + num <= s:
		ans += num
		size += 1
		my_list.append(i)
	if ans == s:
		break
if ans < s:
	print(-1)
else:
	print(size)
	for i in range(size):
		print(my_list[i], end=' ')


import math
t = 1
for _ in range(t):
	a = list(map(int, input().split()))
	summ = a[0]
	limit = a[1]
	r = []
	for i in range(limit, 0, -1):
		if int(bin(i & -i), 2) <= summ:
			r.append(i)
			summ -= int(bin(i & -i), 2)
	if summ:
		print(-1)
	else:
		print(len(r))
		print(*r)


(s, limit) = [int(c) for c in input().split()]

def lowbit(a):
	res = 1
	while a % 2 == 0:
		res += 1
		a = a // 2
	return res
a = [0] * 20
examples = [[] for _ in range(20)]
for i in range(1, limit + 1):
	a[lowbit(i)] += 1
	examples[lowbit(i)].append(i)
length = -1
res = []
c = 1
while s != 0:
	if s <= a[1]:
		res = res + examples[1][:s]
		length += s
		s = 0
	else:
		max_pow = len('{0:b}'.format(s))
		while max_pow != 1 and a[max_pow] == 0:
			max_pow -= 1
		if max_pow == 1:
			length = -2
			s = 0
		else:
			s = s - 2 ** (max_pow - 1)
			length += 1
			ex = examples[max_pow].pop()
			a[max_pow] -= 1
			res.append(ex)
print(length + 1)
if length >= 0:
	print(' '.join(map(str, res)))


(sum, limit) = map(int, input().split())

def lowbit(k):
	count = 0
	for i in k[::-1]:
		if i == '1':
			return 2 ** count
		else:
			count += 1
actual = 0
max = 0
for i in range(1, limit + 1):
	c = bin(i)[2:]
	if lowbit(c) > max:
		max = lowbit(c)
	actual += lowbit(c)
if sum <= actual:
	ans = []
	count = 0
	for i in range(limit, 0, -1):
		count += lowbit(bin(i)[2:])
		ans.append(i)
		if count > sum:
			count -= lowbit(bin(i)[2:])
			ans.pop(-1)
	print(len(ans))
	print(*ans)
else:
	print(-1)


def mi():
	return map(int, input().split())
(s, l) = mi()
r = []
for i in range(l, 0, -1):
	if int(bin(i & -i), 2) <= s:
		r.append(i)
		s -= int(bin(i & -i), 2)
if s:
	print(-1)
else:
	print(len(r))
	print(*r)


def modinv(n, p):
	return pow(n, p - 2, p)
import math

def main():
	(s, limit) = [int(x) for x in input().split()]
	series = []
	for i in range(limit, 0, -1):
		k = int(math.log2(i & -i))
		series.append([2 ** k, i])
	series.sort(reverse=True)
	final_ans = []
	for x in series:
		if s - x[0] >= 0:
			s -= x[0]
			final_ans.append(x[1])
		if s == 0:
			break
	if s != 0:
		print(-1)
	else:
		print(len(final_ans))
		print(*final_ans)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

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

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			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 STR():
	return list(input())

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

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

def MAP2():
	return map(float, input().split())

def LIST():
	return list(map(int, input().split()))

def STRING():
	return input()
import string
import sys
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter, defaultdict
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]

def convert_to_Bin(num):
	arr = []
	while num > 0:
		arr.append(num % 2)
		num //= 2
	d = ''
	for i in range(len(arr) - 1, -1, -1):
		d += str(arr[i])
	return d

def convert_to_d(num):
	base = 1
	res = 0
	while num > 0:
		last_digit = num % 10
		res += last_digit * base
		base *= 2
		num //= 10
	return res
(sm, limit) = MAP()
arr = []
for i in range(1, limit + 1):
	if i % 2 != 0:
		arr.append((i, 1))
	else:
		k = bin(i).replace('0b', '')
		index = 0
		s = []
		for j in range(len(k) - 1, -1, -1):
			s.append(k[j])
			if k[j] == '1':
				index = j
				break
		x = list(reversed(s))
		y = ''.join(x)
		z = convert_to_d(int(y))
		arr.append((i, z))
arr.sort(key=lambda x: x[1], reverse=True)
cnt = 0
res = 0
ans = []
for i in range(len(arr)):
	if res + arr[i][1] <= sm:
		cnt += 1
		res += arr[i][1]
		ans.append(arr[i][0])
if res != sm:
	print(-1)
else:
	print(cnt)
	print(*ans)


from __future__ import division, print_function
import math
import os
import sys
from sys import stdin, stdout
from io import BytesIO, IOBase
from itertools import accumulate
from collections import deque
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def regularbracket(t):
	p = 0
	for i in t:
		if i == '(':
			p += 1
		else:
			p -= 1
		if p < 0:
			return False
	else:
		if p > 0:
			return False
		else:
			return True

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 reverse1(string):
	pp = ''
	for i in string[::-1]:
		pp += i
	if pp == string:
		return True
	return False

def reverse2(list1):
	l = []
	for i in list1[::-1]:
		l.append(i)
	if l == list1:
		return True
	return False
import math

def mex(list1):
	p = max(list1) + 1
	for i in range(len(list1)):
		if list1[i] != i:
			p = i
			break
	return p
l = []
for i in range(1, 30):
	l.append(2 ** i)

def main():
	(sum, limit) = map(int, input().split())
	r = []
	while limit > 0 and sum > 0:
		if sum - (limit & limit) >= 0:
			sum -= limit & -limit
			r.append(limit)
		limit -= 1
	if sum != 0:
		print(-1)
	else:
		print(len(r))
		print(*r)
main()


(m, n) = map(int, input().split())
l = []
for i in range(1, n + 1):
	x = bin(i)
	p = x.split('1')
	l.append((2 ** len(p[-1]), i))
l.sort(reverse=True)
i = 0
ans = []
while m > 0 and i < len(l):
	if m >= l[i][0]:
		m -= l[i][0]
		ans.append(l[i][1])
	i += 1
if m != 0:
	print(-1)
	exit()
print(len(ans))
print(*ans)


import math

def lowerbit(x):
	val = bin(x)[::-1]
	(a, b) = val.split('1', 1)
	a += '1'
	return int(a[::-1], 2)
(s, limit) = map(int, input().split())
org = s
ans = 0
ones = math.ceil(limit / 2)
if s <= ones:
	print(s)
	for i in range(1, limit + 1, 2):
		if s == 0:
			exit(0)
		else:
			s -= 1
			print(i, end=' ')
	exit(0)
if limit % 2 == 1:
	high = limit - 1
else:
	high = limit
red = []
for i in range(high, 0, -2):
	if s <= ones or s == 0:
		break
	elif s - lowerbit(i) >= 0:
		red.append(i)
		s -= lowerbit(i)
		ans += lowerbit(i)
if org == ans:
	print(len(red))
	for i in red:
		print(i, end=' ')
elif ans + ones >= org:
	for i in range(1, limit + 1, 2):
		ans += 1
		red.append(i)
		if ans == org:
			print(len(red))
			for j in red:
				print(j, end=' ')
			exit(0)
else:
	print(-1)


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()

def lowbit(x):
	return x & -x
(s, l) = I()
a = []
for i in range(l, 0, -1):
	x = lowbit(i)
	if x <= s:
		s -= x
		a.append(i)
	if s == 0:
		break
if s != 0:
	print(-1)
	exit()
print(len(a))
print(*a)


(s, l) = map(int, input().split())
d = [list() for _ in range(l)]
ans = list()
for i in range(l):
	d[i] = [int('1' + '0' * bin(i + 1)[2:][::-1].index('1'), 2), i + 1]
for v in reversed(sorted(d)):
	if v[0] <= s:
		s -= v[0]
		ans.append(str(v[1]))
if s > 0:
	print(-1)
else:
	print(len(ans))
	print(' '.join(ans))


def main():
	(_sum, limit) = map(int, input().split())
	ans = []
	for i in range(limit, 0, -1):
		if _sum - (i & -i) >= 0:
			_sum -= i & -i
			ans.append(i)
		if _sum <= 0:
			break
	if _sum > 0:
		print(-1)
	else:
		print(len(ans))
		print(*ans)
main()


def helper(n):
	i = 0
	while n > 0:
		if n & 1 == 1:
			return 2 ** i
		i += 1
		n = n >> 1
(su, limit) = map(int, input().split())
l = [0] * (limit + 1)
tsum = 0
for i in range(1, limit + 1):
	if i % 2 == 0:
		tempi = helper(i)
		l[i] = tempi
		tsum += tempi
	else:
		l[i] = 1
		tsum += 1
if su > tsum:
	print(-1)
else:
	ans = []
	tempsum = su
	index = limit
	while index >= 0 and tempsum > 0:
		if l[index] == su:
			ans = []
			ans.append(index)
			break
		if l[index] <= tempsum:
			ans.append(index)
			tempsum -= l[index]
		if tempsum <= 0:
			break
		index -= 1
	print(len(ans))
	for i in ans:
		print(i, end=' ')
	print()


(s, l) = map(int, input().split())
arr = sorted([(i & -i, i) for i in range(1, l + 1)])
ans = []
for (c, i) in arr[::-1]:
	if s == 0:
		break
	if c <= s:
		ans.append(i)
		s -= c
if s:
	print('-1')
else:
	print(len(ans))
	print(*ans)


from math import log2, ceil
from collections import deque

def lowbit(n):
	s = str(bin(n))[2:]
	i = len(s) - 1
	cnt = 0
	while s[i] != '1':
		i -= 1
		cnt += 1
	return cnt
(s, l) = [int(i) for i in input().split()]
a = []
low = [deque() for i in range(ceil(log2(l)) + 1)]
for i in range(1, l + 1):
	x = lowbit(i)
	low[x].append(i)
i = len(low) - 1
res = []
while i >= 0:
	if s == 0:
		break
	if len(low[i]) > 0 and 2 ** i <= s:
		s -= 2 ** i
		res.append(low[i].popleft())
	else:
		i -= 1
if s == 0:
	print(len(res))
	print(' '.join([str(i) for i in res]))
else:
	print(-1)


(sum, limit) = input().split()
sum = int(sum)
limit = int(limit)
prev_sum = sum
s = []
cur_sum = 0
if sum % 2:
	s.append(1)
	sum -= 1
	cur_sum += 1
count = {}
j = 0
while sum > 0:
	if sum % 2:
		count[2 ** j] = 1
	sum = sum >> 1
	j += 1
occur = [0 for i in range(limit + 1)]
while len(count) > 0:
	cur = next(iter(count))
	if cur == 1:
		i = 1
		if prev_sum % 2:
			i = 3
		while count[cur] > 0 and i <= limit:
			s.append(i)
			cur_sum += 1
			i += 2
			count[cur] -= 1
	elif cur > limit:
		try:
			count[cur // 2] += 2 * count[cur]
		except:
			count[cur // 2] = 2 * count[cur]
	else:
		i = 1
		while count[cur] > 0 and i * cur <= limit:
			while cur * i <= limit and occur[cur * i]:
				i += 2
			if cur * i <= limit:
				s.append(cur * i)
				occur[cur * i] += 1
				cur_sum += cur
				count[cur] -= 1
		if count[cur] != 0:
			try:
				count[cur // 2] += 2 * count[cur]
			except:
				count[cur // 2] = 2 * count[cur]
	del count[cur]
if cur_sum == prev_sum:
	print(len(s))
	for i in s:
		print(i, end=' ')
	print()
else:
	print(-1)


def arr_inp():
	return [int(x) for x in stdin.readline().split()]
from sys import stdin
(all, ans) = ([], [])
(sum, limit) = arr_inp()
for i in range(1, limit + 1):
	if i & 1:
		all.append([i, 1])
	else:
		(c, num) = (1, i)
		while True:
			num >>= 1
			if num & 1:
				all.append([i, 2 ** c])
				break
			c += 1
all.sort(key=lambda x: x[1])
for i in range(limit - 1, -1, -1):
	if all[i][1] <= sum:
		ans.append(all[i][0])
		sum -= all[i][1]
	if sum == 0:
		print(len(ans))
		exit(print(*ans))
print(-1)


from math import *
(s, l) = map(int, input().split())
mL = floor(log2(l))
mS = floor(log2(l))
x = min(mL, mS)
S = []
while x >= 0:
	a = 1
	while 2 ** x <= s and a * 2 ** x <= l:
		S.append(a * 2 ** x)
		a += 2
		s -= 2 ** x
	x -= 1
if s == 0:
	print(len(S))
	print(' '.join(map(str, S)))
else:
	print(-1)


def per(x):
	t = 0
	y = str(bin(x))[2:]
	for i in range(len(y) - 1, -1, -1):
		if y[i] == '1':
			t = i
			break
	return (2 ** (len(y) - t - 1), x)

def perall(l):
	for i in range(1, l + 1):
		ans.append(per(i))
	return ans
(s, l) = map(int, input().split())
ans = []
perall(l)
ans.sort(reverse=True)
answer = []
for i in ans:
	if s - i[0] >= 0:
		s -= i[0]
		answer.append(i[1])
if s != 0:
	print(-1)
else:
	print(len(answer))
	print(*answer)


(s, t) = map(int, input().split())
c = {}
arr = []
for i in range(t, 0, -1):
	l = 0
	tmp = i
	while tmp % 2 == 0:
		tmp /= 2
		l += 1
	if 2 ** l <= s:
		s -= 2 ** l
		arr.append(i)
if s == 0:
	print(len(arr))
	print(*arr)
else:
	print(-1)


(s, l) = map(int, input().split(' '))
li = []
while l != 0 and s != 0:
	x = 1
	if l % 2 == 0:
		g = l
		while g % 2 == 0:
			x += 1
			g = g >> 1
	if s >= pow(2, x - 1):
		s -= pow(2, x - 1)
		li.append(l)
	l -= 1
if s == 0:
	print(len(li))
	print(*li)
else:
	print(-1)


[S, L] = [int(i) for i in input().split()]
d = {}
for i in range(1, L + 1):
	if i % 2 == 1:
		d[i] = 1
	else:
		d[i] = 0
		v = i
		p = 0
		while v % 2 == 0:
			p += 1
			v /= 2
		d[i] = pow(2, p)
d = {k: v for (k, v) in sorted(d.items(), key=lambda item: item[1], reverse=True)}
total = 0
st = []
for (k, v) in d.items():
	if v + total <= S:
		st.append(k)
		total += v
	if total == S:
		break
if total == S:
	print(len(st))
	for i in st:
		print(str(i), end=' ')
else:
	print(-1)


def to_list(s):
	return list(map(lambda x: int(x), s.split(' ')))

def solve(sum_, limit):
	if limit == 1:
		if sum_ > 1:
			return '-1'
		else:
			return ('1', '1')
	else:
		if limit % 2 == 0:
			ones = limit / 2
		else:
			ones = int(limit / 2) + 1
		if sum_ <= ones:
			arr = list(range(1, sum_ * 2, 2))
			s = ' '.join(list(map(lambda x: str(x), arr)))
			return (str(len(arr)), s)
		else:
			a = []
			for i in range(1, limit + 1):
				a.append(2 ** bin(i)[::-1].index('1'))
			cifers = list(range(1, limit + 1))
			zip_a = sorted(zip(a, cifers), key=lambda x: x[0], reverse=True)
			a = [item[0] for item in zip_a]
			cifers = [item[1] for item in zip_a]
			even_idxs = []
			for (i, item) in enumerate(a):
				if item % 2 == 0:
					even_idxs.append(i)
			numbers = []
			for even_idx in even_idxs:
				sum_ -= a[even_idx]
				numbers.append(str(cifers[even_idx]))
				if sum_ <= ones:
					arr = list(map(lambda x: str(x), list(range(1, sum_ * 2, 2))))
					arr.extend(numbers)
					s = ' '.join(arr)
					return (str(len(arr)), s)
	return '-1'
(sum_, limit) = to_list(input())
answer = solve(sum_, limit)
if answer == '-1':
	print('-1')
else:
	print('\n'.join(answer))


(s, l) = map(int, input().split())
odd = l % 2 + l // 2
even = l // 2
limit = l
from math import log2, ceil, floor
allf = 0

def less(i):
	a = 2 ** floor(log2(i))
	return a

def rt(n):
	for i in range(30):
		if n & 1 << i:
			return 1 << i
for i in range(1, l + 1):
	allf += rt(i)
if s > allf:
	print(-1)
	exit()
else:
	res = [rt(i) for i in range(1, limit + 1)]
	r = 0
	ans = []
	for i in range(limit, 0, -1):
		c = rt(i)
		if r + c <= s:
			r += c
			ans.append(i)
	print(len(ans))
	print(*ans)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def getLowBit(num):
	x = str(bin(num))
	j = -1
	for i in range(len(x) - 1, -1, -1):
		j += 1
		if x[i] == '1':
			break
	return j

def main():
	(sumV, limit) = map(int, input().split())
	res = []
	for i in range(1, limit + 1):
		lowBit = 2 ** getLowBit(i)
		res.append([lowBit, i])
	res.sort(key=lambda lowBit: lowBit[0])
	ans = []
	for i in range(len(res) - 1, -1, -1):
		if sumV >= res[i][0]:
			sumV -= res[i][0]
			ans.append(res[i][1])
		if sumV == 0:
			break
	if sumV != 0:
		print(-1)
	else:
		print(len(ans))
		print(*ans, sep=' ')
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math, sys
from collections import defaultdict, deque
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')

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

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

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

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		(n, m) = In()
		d = defaultdict(list)
		for i in range(1, m + 1):
			z = math.log2(i & -i)
			d[int(2 ** z)].append(i)
		l = list(d.keys())
		l.sort(reverse=True)
		ans = []
		for x in l:
			t = min(len(d[x]), n // x)
			for i in range(t):
				ans.append(d[x][i])
			n -= t * x
		if n == 0:
			print(len(ans))
			print(*ans)
		else:
			print(-1)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(1):
	main()


import os
import sys
from io import BytesIO, IOBase
mod = 10 ** 9 + 7

def main():
	(s, l) = map(int, input().split())
	c = 0
	ans = []
	for i in range(l, 0, -1):
		c = i ^ i & i - 1
		if c <= s:
			ans.append(i)
			s -= c
		if s == 0:
			break
	if s == 0:
		print(len(ans))
		print(*ans)
	else:
		print(-1)

def nouse0():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse1():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse2():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
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 nouse3():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse4():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse5():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
main()


from sys import stdin
input = stdin.readline
import math
import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 4)

def lowbit(n):
	return n - (n & n - 1)
(s, limit) = list(map(int, input().split()))
k = math.ceil(math.log(limit, 2))
ans = set()
for i in range(limit, 0, -1):
	x = lowbit(i)
	if s >= x:
		s -= x
		ans.add(i)
if s > 0:
	print(-1)
else:
	print(len(ans))
	for i in ans:
		print(i, end=' ')


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass

def pmat(A):
	for ele in A:
		print(ele, end='\n')
(S, limit) = L()
A = [1 for i in range(limit + 1)]
last = 1
for i in range(1, limit + 1):
	if i == last:
		for j in range(i, limit + 1, last):
			A[j] = last
		last *= 2
B = []
for i in range(1, limit + 1):
	B.append([A[i], i])
B.sort()
ans = []
for i in range(len(B) - 1, -1, -1):
	if S >= B[i][0]:
		S -= B[i][0]
		ans.append(B[i][1])
if S == 0:
	print(len(ans))
	print(*sorted(ans))
else:
	print(-1)
endtime = time.time()


(s, limit) = list(map(int, input().split()))
ans = []
for i in range(limit, 0, -1):
	k = i & (i ^ i - 1)
	if s >= k:
		s -= k
		ans.append(i)
if s:
	print(-1)
else:
	print(len(ans))
	print(*ans)


from math import log2

def lowbit(num):
	binary = '{0:b}'.format(num)
	exp = len(binary) - binary.rfind('1') - 1
	return pow(2, exp)

def main():
	(SUM, LIMIT) = map(int, input().split())
	res = []
	total = 0
	while LIMIT > 0 and SUM > 0:
		if SUM - lowbit(LIMIT) >= 0:
			SUM = SUM - lowbit(LIMIT)
			res.append(LIMIT)
		if SUM == 0:
			print(len(res))
			print(*res, sep=' ')
			return
		LIMIT -= 1
	print(-1)
main()


(n, m) = map(int, input().split())
vals = {}
temp = []
for j in range(1, m + 1):
	lowest_bit = j & -j
	if lowest_bit not in vals:
		vals[lowest_bit] = []
	vals[lowest_bit].append(j)
	temp.append(lowest_bit)
temp.sort()
result = []
for x in reversed(temp):
	if x <= n and len(vals[x]):
		n -= x
		result.append(vals[x][-1])
		vals[x].pop()
if n == 0:
	print(len(result))
	print(*result)
else:
	print(-1)