In a galaxy far, far away Lesha the student has just got to know that he has an exam in two days. As always, he hasn't attended any single class during the previous year, so he decided to spend the remaining time wisely.

Lesha knows that today he can study for at most $a$ hours, and he will have $b$ hours to study tomorrow. Note that it is possible that on his planet there are more hours in a day than on Earth. Lesha knows that the quality of his knowledge will only depend on the number of lecture notes he will read. He has access to an infinite number of notes that are enumerated with positive integers, but he knows that he can read the first note in one hour, the second note in two hours and so on. In other words, Lesha can read the note with number $k$ in $k$ hours. Lesha can read the notes in arbitrary order, however, he can't start reading a note in the first day and finish its reading in the second day.

Thus, the student has to fully read several lecture notes today, spending at most $a$ hours in total, and fully read several lecture notes tomorrow, spending at most $b$ hours in total. What is the maximum number of notes Lesha can read in the remaining time? Which notes should he read in the first day, and which — in the second?


-----Input-----

The only line of input contains two integers $a$ and $b$ ($0 \leq a, b \leq 10^{9}$) — the number of hours Lesha has today and the number of hours Lesha has tomorrow.


-----Output-----

In the first line print a single integer $n$ ($0 \leq n \leq a$) — the number of lecture notes Lesha has to read in the first day. In the second line print $n$ distinct integers $p_1, p_2, \ldots, p_n$ ($1 \leq p_i \leq a$), the sum of all $p_i$ should not exceed $a$.

In the third line print a single integer $m$ ($0 \leq m \leq b$) — the number of lecture notes Lesha has to read in the second day. In the fourth line print $m$ distinct integers $q_1, q_2, \ldots, q_m$ ($1 \leq q_i \leq b$), the sum of all $q_i$ should not exceed $b$.

All integers $p_i$ and $q_i$ should be distinct. The sum $n + m$ should be largest possible.


-----Examples-----
Input
3 3

Output
1
3 
2
2 1 
Input
9 12

Output
2
3 6
4
1 2 4 5



-----Note-----

In the first example Lesha can read the third note in $3$ hours in the first day, and the first and the second notes in one and two hours correspondingly in the second day, spending $3$ hours as well. Note that Lesha can make it the other way round, reading the first and the second notes in the first day and the third note in the second day.

In the second example Lesha should read the third and the sixth notes in the first day, spending $9$ hours in total. In the second day Lesha should read the first, second fourth and fifth notes, spending $12$ hours in total.

Difficulty: MEDIUM_HARD
Tags: Greedy algorithms
Skill types: Greedy algorithms

Starter code:

Solutions:
import os
import sys
from io import BytesIO, IOBase
from collections import defaultdict

def main():
	(a, b) = map(int, input().split())
	(ans, p, q) = ([], [], [])
	(i, z) = (1, 0)
	while z + i <= a + b:
		z += i
		ans.append(i)
		i += 1
	for i in range(len(ans) - 1, -1, -1):
		if a >= ans[i]:
			p.append(ans[i])
			a -= ans[i]
	b = set(p)
	for i in ans:
		if i not in b:
			q.append(i)
	print(len(p))
	print(*p)
	print(len(q))
	print(*q)
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()


(a, b) = map(int, input().split(' '))
s = 0
k = 0
c = '1'
q = 0
while s < a + b:
	k = k + 1
	s += k
	c = c + '0'
n = k
if s > a + b:
	c = c[:s - a - b] + '1' + c[s - a - b + 1:]
	n = k - 1
l = k
m = 0
while m < a:
	if c[l] == '0':
		c = c[:l] + '2' + c[l + 1:]
		m = m + l
		q += 1
	l = l - 1
c = c[:l + 1] + '0' + c[l + 2:]
c = c[:a - m + l + 1] + '2' + c[a - m + l + 2:]
print(q)
for i in range(1, k + 1):
	if c[i] == '2':
		print(i, end=' ')
print()
if n - q > 0:
	print(n - q)
	for i in range(1, k + 1):
		if c[i] == '0':
			print(i, end=' ')
else:
	print(0)


from sys import setcheckinterval, stdin, setrecursionlimit
setcheckinterval(1000)
setrecursionlimit(10 ** 7)

def iin():
	return int(stdin.readline())

def lin():
	return list(map(int, stdin.readline().split()))
(a, b) = lin()
A = a
ch = 1
ch1 = 1
while ch1 <= a + b:
	ch += 1
	ch1 += ch
a1 = []
a2 = []
for i in range(ch - 1, 0, -1):
	if a - i >= 0:
		a1.append(i)
		a -= i
	else:
		a2.append(i)
print(len(a1))
print(*a1)
print(len(a2))
print(*a2)


(a, b) = map(int, input().split())
t = a + b
cnt = 0
for i in range(10 ** 9):
	cnt += 1
	if cnt * (cnt + 1) // 2 > t:
		cnt -= 1
		break
firstday = []
secondday = []
for x in range(cnt, 0, -1):
	if a >= x:
		firstday.append(x)
		a -= x
	else:
		secondday.append(x)
		b -= x
print(len(firstday))
print(*firstday)
print(len(secondday))
print(*secondday)


(a, b) = map(int, input().split())
curr = a
ind = 1
f = []
s = []
while curr >= ind:
	f.append(ind)
	curr -= ind
	ind += 1
extra = -1
if curr and ind - curr <= ind:
	f.append(ind)
	extra = ind - curr
	ind += 1
curr = b
while curr >= ind:
	s.append(ind)
	curr -= ind
	ind += 1
if extra != -1:
	print(len(f) - 1)
	for i in f:
		if i != extra:
			print(i, end=' ')
	print('')
	if curr >= extra:
		print(len(s) + 1)
		print(extra, end=' ')
		for i in s:
			print(i, end=' ')
	else:
		print(len(s))
		for i in s:
			print(i, end=' ')
	print('')
else:
	print(len(f))
	for i in f:
		print(i, end=' ')
	print('')
	print(len(s))
	for i in s:
		print(i, end=' ')
	print('')


(a, b) = map(int, input().split())
arr = []
sum_ = a + b
k = 1
while sum_ >= k:
	arr.append(k)
	sum_ -= k
	k += 1
(a1, b1) = ([], [])
for i in range(len(arr) - 1, -1, -1):
	if a >= arr[i]:
		a -= arr[i]
		a1.append(arr[i])
	elif b >= arr[i]:
		b -= arr[i]
		b1.append(arr[i])
print(len(a1))
print(' '.join(map(str, a1)))
print(len(b1))
print(' '.join(map(str, b1)))


(a, b) = map(int, input().split())
c = False
if b < a:
	c = True
	(a, b) = (b, a)
xa = 0
n = 0
while a >= (xa + 1) * xa // 2:
	xa += 1
xa -= 1
xb = 0
if c == False:
	print(xa)
sa = (xa + 1) * xa // 2
xb = xa + 1
x = xa + 1 - (a - sa)
flag = False
if a - sa != 0 and b >= x:
	flag = True
	b -= x
	xb = xa + 2
	if c == False:
		for i in range(xa):
			if i != x - 1:
				print(i + 1, sep=' ', end=' ')
		print(xa + 1, sep=' ', end=' ')
		print()
elif c == False:
	for i in range(xa):
		print(i + 1, sep=' ', end=' ')
	print()
r = xb
xb = 0
while b >= (2 * r + xb) * (xb + 1) // 2:
	xb += 1
xb -= 1
if flag == False:
	print(xb + 1)
	for i in range(xa, r + xb):
		print(i + 1, sep=' ', end=' ')
else:
	print(xb + 2)
	for i in range(xa + 1, r + xb):
		print(i + 1, sep=' ', end=' ')
	print(x)
if c == True:
	print(xa)
	if flag == True:
		for i in range(xa):
			if i != x - 1:
				print(i + 1, sep=' ', end=' ')
		print(xa + 1, sep=' ', end=' ')
		print()
	else:
		for i in range(xa):
			print(i + 1, sep=' ', end=' ')
		print()


(a, b) = map(int, input().split())
k = 0
while k * (k + 1) // 2 <= a + b:
	k += 1
k -= 1
A = []
for i in range(1, k + 1):
	A.append(i)
List_1 = []
for i in range(k - 1, -1, -1):
	if A[i] <= a:
		List_1.append(A[i])
		a -= A[i]
		A.pop(i)
print(len(List_1))
print(*List_1)
print(len(A))
print(*A)


from __future__ import print_function
from collections import *
from sys import stdin
from bisect import *
from heapq import *
from math import log2
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
rr = lambda x: reversed(range(x))
mod = int(1000000000.0) + 7
inf = float('inf')
(a, b) = gil()
rev = False
if a > b:
	rev = True
	(a, b) = (b, a)
(l, r) = (1, int(1000000000.0))
ans = 0
while l <= r:
	mid = (l + r) // 2
	if mid * (mid + 1) // 2 <= a:
		ans = mid
		l = mid + 1
	else:
		r = mid - 1
newSum = (ans + 1) * (ans + 2) // 2
miss = inf if newSum - a > ans + 1 else newSum - a
if miss != inf:
	ans += 1
(aa, bb) = ([], [])
for v in range(1, ans + 1):
	if v != miss:
		aa.append(v)
sm = 0
start = ans + 1
while sm + start < b:
	bb.append(start)
	sm += start
	start += 1
if sm + miss <= b:
	bb.append(miss)
if rev:
	(aa, bb) = (bb, aa)
print(len(aa))
print(*aa)
print(len(bb))
print(*bb)


(a, b) = map(int, input().split())
max_lectures = a + b
n = 1
while n * (n + 1) / 2 <= a + b:
	n = n + 1
n = n - 1
a_list = []
b_list = []
a_sum = 0
b_sum = 0
for i in range(n, 0, -1):
	if a_sum + i <= a:
		a_list.append(i)
		a_sum = a_sum + i
	elif b_sum + i <= b:
		b_list.append(i)
		b_sum = b_sum + i
print(len(a_list))
print(*a_list)
print(len(b_list))
print(*b_list)


(a, b) = map(int, input().split())
c = []
e = []
i = 1
s = 1
c.append(i)
e.append(i)
while s <= a + b:
	i += 1
	s += i
	c.append(i)
	e.append(i)
i = i - 1
c.pop()
e.pop()
i -= 1
j = -1
d = []
while j < i:
	if c[i] <= a:
		d.append(c[i])
		a -= c[i]
		e.pop(i)
	i -= 1
print(len(d))
for i in d:
	print(i, end=' ')
print()
print(len(e))
for i in e:
	print(i, end=' ')


import collections, atexit, math, sys, bisect
sys.setrecursionlimit(1000000)

def getIntList():
	return list(map(int, input().split()))
try:
	import numpy

	def dprint(*args, **kwargs):
		print(*args, **kwargs, file=sys.stderr)
	dprint('debug mode')
except Exception:

	def dprint(*args, **kwargs):
		pass
inId = 0
outId = 0
if inId > 0:
	dprint('use input', inId)
	sys.stdin = open('input' + str(inId) + '.txt', 'r')
if outId > 0:
	dprint('use output', outId)
	sys.stdout = open('stdout' + str(outId) + '.txt', 'w')
	atexit.register(lambda : sys.stdout.close())
(A, B) = getIntList()
tot = 0
for i in range(1, 1000000):
	tot += i
	if tot > A + B:
		break
n = i - 1
zr = [1 for i in range(n + 1)]
tot = 0
zz = []
for i in range(1, 1000000):
	tot += i
	if tot > A:
		tot -= i
		break
	zz.append(i)
if zz and zz[-1] < n:
	for i in range(A - tot):
		zz[-1 - i] += 1
for x in zz:
	zr[x] = 0
print(len(zz))
for x in zz:
	print(x, end=' ')
print()
print(n - len(zz))
for i in range(1, n + 1):
	if zr[i] == 1:
		print(i, end=' ')
print()


(a, b) = map(int, input().split())
total = a + b
s = 0
e = 10000000000.0
while s != e:
	g = (s + e + 1) // 2
	if g * (g + 1) // 2 > total:
		e = g - 1
	else:
		s = g
total_book = int(s)
books = [i for i in range(1, total_book + 1)]
first_day = []
sec_day = []
k = len(books)
if a >= b:
	while k != 0 and a != 0:
		if a in books:
			first_day.append(a)
			c = a
			a -= books[c - 1]
			del books[c - 1]
		else:
			a -= books[-1]
			first_day.append(books[-1])
			del books[-1]
		k = len(books)
	sec_day = books[:]
else:
	while k != 0 and b != 0:
		if b in books:
			sec_day.append(b)
			c = b
			b -= books[c - 1]
			del books[c - 1]
		else:
			b -= books[-1]
			sec_day.append(books[-1])
			del books[-1]
		k = len(books)
	first_day = books[:]
print(len(first_day))
for book in first_day:
	print(book, end=' ')
print()
print(len(sec_day))
for book in sec_day:
	print(book, end=' ')
print()


import math
(a, b) = map(int, input().split())
sq = int((-1 + math.sqrt(1 + 8 * (a + b))) // 2)
ans1 = set()
ans2 = set()
for i in range(1, sq + 1):
	ans2.add(str(i))
for i in range(sq, 0, -1):
	if a == 0:
		break
	cur = min(a, i)
	a -= cur
	ans2.remove(str(cur))
	ans1.add(str(cur))
print(len(ans1))
print(' '.join(ans1))
print(len(ans2))
print(' '.join(ans2))


import math
(day1, day2) = list(map(int, input().split()))
n = math.floor((-1 + math.sqrt(1 + 8 * (day1 + day2))) / 2)
l = range(1, n + 1)[-1::-1]
day1_list = []
for c in l:
	if c <= day1:
		day1 -= c
		day1_list.append(c)
print(len(day1_list))
print(' '.join(map(str, day1_list)))
day2_list = set(l) - set(day1_list)
print(len(day2_list))
print(' '.join(map(str, day2_list)))


import sys
import string
from math import gcd
import getpass
import math
from decimal import Decimal

def ria():
	return [int(i) for i in input().split()]
if getpass.getuser() != 'frohenk':
	filename = 'half'
else:
	sys.stdin = open('input.txt')

def a(v):
	return int((v + 1) * (v / 2))

def oid(n, ad):
	l = 0
	r = ad
	while l < r:
		m = (l + r) // 2
		df = a(ad) - a(m)
		if df > n:
			l = m + 1
		else:
			r = m
	return l
(v1, v2) = ria()
sm = v1 + v2
l = 0
r = 1000000000
while l < r:
	m = (l + r + 1) // 2
	if a(m) > sm:
		r = m - 1
	else:
		l = m
kot = l
aba = set()
bba = set()
for i in range(kot, 0, -1):
	if v1 >= i:
		aba.add(i)
		v1 -= i
	else:
		bba.add(i)
print(len(aba))
for i in aba:
	print(i, end=' ')
print()
print(len(bba))
for i in bba:
	print(i, end=' ')


def main():
	(a, b) = map(int, input().split())
	if a + b == 0:
		print(0)
		print(0)
		return
	_sum = 0
	last = 0
	for i in range(1, a + b + 1):
		_sum += i
		if _sum == a + b:
			last = i
			break
		elif _sum > a + b:
			_sum -= i
			last = i - 1
			break
	first = 1
	current = last
	used = set()
	q_1 = min(a, b)
	q = q_1
	if q <= last:
		if q == 0:
			pass
		else:
			used.add(q)
	else:
		while q >= current:
			used.add(current)
			q -= current
			current -= 1
		if q != 0:
			used.add(q)
	if q_1 == a:
		print(len(used))
		print(*used)
		print(last - len(used))
		print(*used ^ {i for i in range(1, last + 1)})
		return
	else:
		print(last - len(used))
		print(*used ^ {i for i in range(1, last + 1)})
		print(len(used))
		print(*used)
		return
main()


(a, b) = map(int, input().split())
i = 1
s = i
ind = [i]
sums = 0
sums1 = 0
u = []
p = []
while s < a + b:
	i += 1
	s += i
	ind.append(i)
	if s > a + b:
		ind.remove(i)
if a <= b:
	for j in range(-len(ind) + 1, 1):
		if a - ind[-j] >= 0 and j <= 0:
			sums += 1
			u.append(ind[-j])
			a -= ind[-j]
		elif b > 0:
			sums1 += 1
			p.append(ind[-j])
			b -= ind[-j]
else:
	for j in range(-len(ind) + 1, 1):
		if b - ind[-j] >= 0 and j <= 0:
			sums1 += 1
			p.append(ind[-j])
			b -= ind[-j]
		elif a > 0:
			sums += 1
			u.append(ind[-j])
			a -= ind[-j]
u.reverse()
p.reverse()
print(sums)
print(*u)
print(sums1)
print(*p)


(a, b) = list(map(int, input().split()))
x = a + b
n = int((1 + 8 * x) ** 0.5 / 2 - 0.5)
flag = 0
if a > b:
	(a, b) = (b, a)
	flag = 1
ar1 = []
num1 = 0
for i in range(n, 0, -1):
	if a - num1 >= i:
		ar1.append(i)
		num1 += i
ar2 = []
for i in range(1, n + 1):
	if i not in ar1:
		ar2.append(i)
if flag == 0:
	print(len(ar1))
	print(' '.join(map(str, ar1)))
	print(len(ar2))
	print(' '.join(map(str, ar2)))
else:
	print(len(ar2))
	print(' '.join(map(str, ar2)))
	print(len(ar1))
	print(' '.join(map(str, ar1)))


(a, b) = map(int, input().split())
if a == 1 and b == 1:
	print(1)
	print(1)
	print(0)
	exit()
k = 0
p = 0
for i in range(1, 1000000):
	k += i
	if k >= a + b:
		p = i
		break
d = k - a - b
k1 = 0
p1 = 0
for i in range(1, 1000000):
	k1 += i
	if k1 >= a:
		p1 = i
		break
d1 = k1 - a
ans = []
ans1 = []
d3 = 0
d4 = 0
if d <= p1 and d != d1 and (d != 0):
	if p1 + 1 - d != d1:
		ans1.append(p1 + 1)
		d3 = p1 + 1 - d
		d4 = p1 + 1
	else:
		ans1.append(p1 + 2)
		d3 = p1 + 2 - d
		d4 = p1 + 2
for i in range(1, p + 1):
	if i != d and i != d4:
		ans.append(i)
for i in range(1, p1 + 1):
	if i != d1 and i != d and (i != d3):
		ans1.append(i)
print(len(ans1))
print(' '.join(map(str, ans1)))
ans1 = set(ans1)
ans2 = []
for i in range(len(ans)):
	if ans[i] not in ans1:
		ans2.append(ans[i])
print(len(ans2))
print(' '.join(map(str, ans2)))


import math
(A, B) = list(map(int, input().split()))
a = []
b = []
cur = 0
while cur * (cur + 1) <= 2 * (A + B):
	cur += 1
cur -= 1
for i in range(cur, 0, -1):
	if i <= A:
		a.append(str(i))
		A -= i
	elif i <= B:
		b.append(str(i))
		B -= i
print(len(a))
print(' '.join(a))
print(len(b))
print(' '.join(b))


(a, b) = map(int, input().split())
sum = a + b
m = 1
s = 0
while s + m <= sum:
	s += m
	m += 1
m -= 1
al = []
bl = []
for i in range(m, 0, -1):
	if a - i >= 0:
		al.append(i)
		a -= i
	elif b - i >= 0:
		bl.append(i)
		b -= i
print(len(al))
print(' '.join(map(str, al)))
print(len(bl))
print(' '.join(map(str, bl)))


import math
(a, b) = map(int, input().split())
total = a + b

def cal(t):
	n = max(0, int(math.sqrt(2 * t)) - 1)
	while n * (n + 1) // 2 <= t:
		n += 1
	return n - 1
n = cal(total)
swap = False
if a > b:
	swap = True
	(a, b) = (b, a)
na = cal(a) + 1
ansa = {i for i in range(1, na + 1)}
sa = na * (na + 1) // 2
ansa.discard(sa - a)
ansb = {i for i in range(1, n + 1)} - ansa
if swap:
	(ansa, ansb) = (ansb, ansa)
print(len(ansa))
if ansa:
	print(' '.join(map(str, ansa)))
print(len(ansb))
if ansb:
	print(' '.join(map(str, ansb)))


(a, b) = map(int, input().split())
g = False
if b < a:
	g = True
	(a, b) = (b, a)
na = 0
nb = 0
n = 0
while a >= (na + 1) * na // 2:
	na += 1
na -= 1
if g == False:
	print(na)
sa = (na + 1) * na // 2
nb = na + 1
x = na + 1 - (a - sa)
f = False
if a - sa != 0 and b >= x:
	f = True
	b -= x
	nb = na + 2
	if g == False:
		for i in range(na):
			if i != x - 1:
				print(i + 1, sep=' ', end=' ')
		print(na + 1, sep=' ', end=' ')
		print()
elif g == False:
	for i in range(na):
		print(i + 1, sep=' ', end=' ')
	print()
h = nb
nb = 0
while b >= (2 * h + nb) * (nb + 1) // 2:
	nb += 1
nb -= 1
if f == False:
	print(nb + 1)
	for i in range(na, h + nb):
		print(i + 1, sep=' ', end=' ')
else:
	print(nb + 2)
	for i in range(na + 1, h + nb):
		print(i + 1, sep=' ', end=' ')
	print(x)
if g == True:
	print(na)
	if f == True:
		for i in range(na):
			if i != x - 1:
				print(i + 1, sep=' ', end=' ')
		print(na + 1, sep=' ', end=' ')
		print()
	else:
		for i in range(na):
			print(i + 1, sep=' ', end=' ')
		print()


def get_out(list):
	print(len(list))
	out = ' '.join(list)
	print(out)
arr = input().split()
a = int(arr[0])
b = int(arr[1])
s = a + b
temp = 0
i = 0
while temp <= s:
	i += 1
	temp += i
i -= 1
list_a = []
list_b = []
for x in range(i, 0, -1):
	if a - x >= 0:
		a -= x
		list_a.append(str(x))
	elif b - x >= 0:
		b -= x
		list_b.append(str(x))
get_out(list_a)
get_out(list_b)


(a, b) = map(int, input().split())
s = a + b
n = 0
k = 1
A = []
while n <= s:
	A.append(k)
	n += k
	k += 1
n -= k - 1
k -= 2
A = A[:k]
P = []
Q = []
for i in range(k - 1, -1, -1):
	if a - A[i] >= 0:
		P.append(A[i])
		a -= A[i]
	else:
		Q.append(A[i])
		b -= A[i]
print(len(P))
print(*P)
print(len(Q))
print(*Q)


(a, b) = map(int, input().split())
limit = 1
s = a + b
num = 0
while s >= num + limit:
	num += limit
	limit += 1
limit -= 1
a_array = []
b_array = []
for i in range(limit, 0, -1):
	if i <= a:
		a_array.append(i)
		a -= i
	elif i <= b:
		b_array.append(i)
		b -= i
print(len(a_array))
print(*a_array)
print(len(b_array))
print(*b_array)


from sys import stdout
from math import sqrt
(n, k) = map(int, input().split())
no = (-1 + int(sqrt(1 + 8 * n))) // 2
nn = n - no * (no + 1) / 2
if nn != 0:
	nn = no + 1 - nn
(d1, d2) = ([], [])
i = 1
while n > 0:
	if i != nn:
		n -= i
		d1.append(i)
	i += 1
print(len(d1))
print(*d1)
if nn != 0:
	if k >= nn:
		d2.append(int(nn))
		k -= nn
while k > 0:
	k -= i
	if k >= 0:
		d2.append(i)
	i += 1
print(len(d2))
print(*d2)


(a, b) = map(int, input().split())
(left, right) = (0, 10 ** 5)
while left != right - 1:
	mid = (left + right) // 2
	(a1, b1) = (min(a, b), max(a, b))
	for k in range(mid, 0, -1):
		if k <= a1:
			a1 -= k
		else:
			b1 -= k
	if min(a1, b1) < 0:
		right = mid
	else:
		left = mid
(a1, b1) = (min(a, b), max(a, b))
(x, y) = ([], [])
for k in range(left, 0, -1):
	if k <= a1:
		a1 -= k
		x.append(k)
	else:
		b1 -= k
		y.append(k)
if a > b:
	(x, y) = (y, x)
print(len(x))
print(*x)
print(len(y))
print(*y)


def ans_1():
	print(len(day1))
	for j in day1:
		print(j, end=' ')

def ans_2():
	print(i - len(day1) - 1 - 1)
	for j in range(i - 2, 0, -1):
		if j not in day1:
			print(j, end=' ')
(a, b) = map(int, input().split())
(c, d) = (a, b)
(a, b) = (min(a, b), max(a, b))
total = a + b
count = 0
i = 1
pre = 0
while count <= total:
	count += i
	pre = i
	i += 1
pre -= 1
day1 = set()
adda = 0
last = 0
while adda < a:
	adda += pre
	day1.add(pre)
	last = pre
	pre -= 1
if day1:
	day1.remove(last)
	day1.add(last - (adda - a))
if c < d:
	ans_1()
	print()
	ans_2()
else:
	ans_2()
	print()
	ans_1()


from math import sqrt

def cram_time():
	(a, b) = map(int, input().split())
	n = int(sqrt(2 * (a + b)) - 2)
	while (n + 1) * (n + 2) / 2 <= a + b:
		n += 1
	tasks = list(range(n, 0, -1))
	t1 = []
	t2 = []
	while tasks:
		current_task = tasks.pop(0)
		if current_task <= a:
			t1.append(current_task)
			a -= current_task
		else:
			t2.append(current_task)
			b -= current_task
	print(len(t1))
	print(' '.join(list(map(str, t1))))
	print(len(t2))
	print(' '.join(list(map(str, t2))))
cram_time()


a = input()
(a, b) = a.split(' ')
a = int(a)
b = int(b)

def binary_search(val):
	(l, r, ans) = (1, val, -1)
	while l <= r:
		mid = (l + r) // 2
		if mid * (mid + 1) <= 2 * val:
			ans = mid
			l = mid + 1
		else:
			r = mid - 1
	return ans
val = binary_search(a + b)
lista = []
listb = []
vis = [0] * (val + 1)
t = val
while a > 0 and t > 0:
	if a >= t:
		vis[t] = 1
		lista.append(t)
		a -= t
		t -= 1
	else:
		vis[a] = 1
		lista.append(a)
		a = 0
t = 1
while b > 0:
	if b < t:
		break
	elif vis[t] == 1:
		t += 1
	else:
		b -= t
		listb.append(t)
		t += 1
print(len(lista))
for x in lista:
	print(x, end=' ')
print('\n')
print(len(listb))
for x in listb:
	print(x, end=' ')


def f(n):
	return n * (n + 1) // 2

def process(n, m):
	x = n + m
	start = 0
	end = 2 * x
	while start + 1 < end:
		M = (start + end) // 2
		if f(M) > x:
			(start, end) = (start, M)
		else:
			(start, end) = (M, end)
	a = []
	s = start
	b = set(range(1, start + 1))
	while n > 0 and s > 0:
		if n < s:
			a.append(n)
			b.remove(n)
			n = 0
			break
		else:
			a.append(s)
			b.remove(s)
			n -= s
			s -= 1
	return [a, b]
(n, m) = [int(x) for x in input().split()]
(a, b) = process(n, m)
print(len(a))
print(' '.join(map(str, a)))
print(len(b))
print(' '.join(map(str, b)))


def print_set(n):
	print(len(n))
	n = [str(i) for i in n]
	print(' '.join(n))
(a, b) = map(int, input().split())
s = a + b
used = 0
k = 1
A = []
B = []
while used + k <= s:
	used += k
	k += 1
k -= 1
while k > 0:
	if k <= a:
		A.append(k)
		a -= k
	else:
		b -= k
		B.append(k)
	k -= 1
print_set(A)
print_set(B)


from sys import stdin, stdout

def readlist():
	a = [int(i) for i in stdin.readline().split()]
	return a

def root(a):
	p = (1 + 8 * a) ** 0.5 - 1
	p = p / 2
	return int(p)
(c, d) = readlist()
if c > d:
	a = d
	b = c
	fl = 1
else:
	b = d
	a = c
	fl = 0
p = root(a)
z = list(range(1, p + 1))
extra = a - p * (p + 1) // 2
i = len(z) - 1
while extra > 0:
	z[i] = z[i] + 1
	i = i - 1
	extra = extra - 1
q = root(a + b)
z1 = list(range(1, q)) + [q + (a + b - q * (q + 1) // 2)]
z1 = list(set(z1) - set(z))
if sum(z1) != b:
	z1.remove(max(z1))
if fl == 1:
	if b == 0:
		print(0)
		print(' ')
	else:
		print(len(z1))
		print(*z1)
	if a == 0:
		print(0)
		print(' ')
	else:
		print(len(z))
		print(*z)
else:
	if a == 0:
		print(0)
		print(' ')
	else:
		print(len(z))
		print(*z)
	if b == 0:
		print(0)
		print(' ')
	else:
		print(len(z1))
		print(*z1)


(a, b) = input().split()
(a, b) = (int(a), int(b))
c = a + b
i = 0
resa = []
resb = []
while c > 0:
	i += 1
	c -= i
if c < 0:
	i -= 1
for j in range(i, 0, -1):
	if a - j >= 0:
		a -= j
		resa.append(j)
	else:
		b -= j
		resb.append(j)
print(len(resa))
for j in range(len(resa)):
	print(resa[j], end=' ')
print('\n' + str(len(resb)))
for j in range(len(resb)):
	print(resb[j], end=' ')


(A, B) = map(int, input().split())
s = A + B
c = 0
k = 0
while c <= s:
	k += 1
	c += k
k -= 1
n = list()
m = list()
if A < B:
	while k:
		if A >= k:
			n.append(k)
			A -= k
		else:
			m.append(k)
		k -= 1
else:
	while k:
		if B >= k:
			m.append(k)
			B -= k
		else:
			n.append(k)
		k -= 1
print(len(n))
print(*n)
print(len(m))
print(*m)


(a, b) = map(int, input().split())
n = int((1 + (1 + 8 * (a + b)) ** 0.5) / 2 - 1)
con = [x for x in range(1, n + 1)]
con = con[::-1]
con1 = []
con2 = []
a1 = a
b1 = b
a = max(a, b)
b = min(a1, b1)
for i in range(0, len(con)):
	if a - con[i] > 0:
		con1.append(con[i])
		a -= con[i]
		con[i] = 0
	elif a - con[i] == 0:
		con1.append(con[i])
		con[i] = 0
		break
con2 = []
for i in con:
	if i != 0:
		con2.append(i)
a2 = len(con1)
b2 = len(con2)
huy = con1[::-1]
huy1 = con2[::-1]
if a1 <= b1:
	print(b2)
	print(*huy1)
	print(a2)
	print(*huy)
else:
	print(a2)
	print(*huy)
	print(b2)
	print(*huy1)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

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

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

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		(a, b) = ria()
		f = {}
		i = 1
		while a > 0:
			a -= i
			f[i] = 1
			i += 1
		if a < 0:
			del f[-a]
		aans = []
		for i in f:
			aans.append(i)
		print(len(aans))
		print(*aans)
		i = 1
		bans = []
		while b - i >= 0:
			if i not in f:
				b -= i
				bans.append(i)
			i += 1
		print(len(bans))
		print(*bans)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


from math import *
(a, b) = (int(e) for e in input().split(' '))
desc = 1 + 4 * 2 * (a + b)
xf = 0.5 * (sqrt(desc) - 1)
x = floor(xf)
arrA = []
tempA = a
for i in range(x, 0, -1):
	if tempA == 0:
		break
	if tempA - i > 0:
		arrA.append(i)
		tempA -= i
	else:
		arrA.append(tempA)
		break
arrB = list(set(range(x, 0, -1)) - set(arrA))
print(len(arrA))
print(*arrA)
print(len(arrB))
print(*arrB)


import sys
(a, b) = map(int, input().split())
f = 0
if b > a:
	(a, b) = (b, a)
	f = 1
cop = a
n = 1
fir = []
sec = []
while a >= n:
	a -= n
	fir.append(n)
	n += 1
if b == 0:
	if f == 0:
		print(len(fir))
		print(*fir, sep=' ')
		print(0)
	else:
		print(0)
		print(len(fir))
		print(*fir, sep=' ')
	sys.exit()
if a != 0:
	fir.append(n)
	s = sum(fir) - cop
	fir.remove(s)
	sec.append(s)
	b -= s
	n += 1
while b >= n:
	b -= n
	sec.append(n)
	n += 1
if f == 1:
	print(len(sec))
	print(*sec, sep=' ')
	print(len(fir))
	print(*fir, sep=' ')
else:
	print(len(fir))
	print(*fir, sep=' ')
	print(len(sec))
	print(*sec, sep=' ')


(a, b) = map(int, input().split())
array1 = []
array2 = []
array3 = []
array4 = []
l = 0
r = 10000000000
while r - l > 1:
	m = (l + r) // 2
	if (m + 1) / 2 * m > a + b:
		r = m
	else:
		l = m
summ1 = 0
summ2 = 0
for i in range(l, 0, -1):
	if a - summ1 >= i:
		array1.append(i)
		summ1 = summ1 + i
	elif b - summ2 >= i:
		array2.append(i)
		summ2 = summ2 + i
summ1 = 0
summ2 = 0
for i in range(r, 0, -1):
	if a - summ1 >= i:
		array3.append(i)
		summ1 = summ1 + i
	elif b - summ2 >= i:
		array4.append(i)
		summ2 = summ2 + i
if len(array1) + len(array2) > len(array3) + len(array4):
	print(len(array1))
	print(*array1)
	print(len(array2))
	print(*array2)
else:
	print(len(array3))
	print(*array3)
	print(len(array4))
	print(*array4)


(a, b) = map(int, input().split())

def numbers(n):
	resp = []
	curr = 1
	while n >= curr:
		resp.append(curr)
		n -= curr
		curr += 1
	return resp
num = numbers(a + b)
anum = set()
for x in num[::-1]:
	if a >= x:
		a -= x
		anum.add(x)
print(len(anum))
for x in anum:
	print(x, end=' ')
print()
bnum = set(num) - anum
print(len(bnum))
for x in bnum:
	print(x, end=' ')
print()


import math
w = input().split(' ')
a = int(w[0])
b = int(w[1])
day1 = []
day2 = []
k = int(math.sqrt(2 * a + 2 * b))
used = []
for i in range(k):
	used.append(False)
if a < b:
	for i in range(k):
		if a >= k - i:
			day1.append(k - i)
			a -= k - i
			used[k - i - 1] = True
	for i in range(k):
		if b >= i + 1 and (not used[i]):
			day2.append(i + 1)
			b -= i + 1
else:
	for i in range(k):
		if b >= k - i:
			day2.append(k - i)
			b -= k - i
			used[k - i - 1] = True
	for i in range(k):
		if a >= i + 1 and (not used[i]):
			day1.append(i + 1)
			a -= i + 1
print(len(day1))
for i in day1:
	print(i, end=' ')
print()
print(len(day2))
for i in day2:
	print(i, end=' ')


import math, sys

def mp():
	return list(map(int, input().split()))
deb = 0
if deb:
	f = open('input.txt', 'r')
	input = f.readline
else:
	input = sys.stdin.readline

def main():
	(a, b) = mp()
	s = a + b
	i = 0
	k = 0
	while True:
		if i + k + 1 <= s:
			k += 1
			i += k
		else:
			break
	ans1 = []
	ans2 = []
	for i in range(k, 0, -1):
		if i <= a:
			a -= i
			ans1.append(i)
		elif i <= b:
			b -= i
			ans2.append(i)
		else:
			assert false
	print(len(ans1))
	for i in ans1:
		print(i, end=' ')
	print()
	print(len(ans2))
	for i in ans2:
		print(i, end=' ')
main()


def main():
	(a, b) = map(int, input().split())
	mx = max(a, b)
	mn = min(a, b)
	s = mx + mn
	k = int(0.5 * ((1 + 8 * s) ** 0.5 - 1))
	rk = range(k, 0, -1)
	st = {i: True for i in rk}
	(r1, r2) = (mn, mx)
	(xe, ie) = (0, 0)
	for k in rk:
		if k <= r1:
			st[k] = 'min'
			ie += 1
			r1 -= k
		else:
			st[k] = 'max'
			xe += 1
			r2 -= k
	if a == mx:
		(a_k, b_k) = ('max', 'min')
		(a_q, b_q) = (xe, ie)
	else:
		(a_k, b_k) = ('min', 'max')
		(a_q, b_q) = (ie, xe)
	print(a_q)
	for e in st:
		if st[e] == a_k:
			print(e, end=' ')
	print()
	print(b_q)
	for e in st:
		if st[e] == b_k:
			print(e, end=' ')
	print()
main()


(a, b) = map(int, input().split())
k = 1
a_m = []
m = []
s = 0
while s <= a + b:
	s += k
	m.append(k)
	k += 1
del m[-1]
for i in range(k - 3, -1, -1):
	if a >= m[i]:
		a -= m[i]
		a_m.append(m[i])
		del m[i]
print(len(a_m))
print(*a_m)
print(len(m))
print(*m)


(a, b) = [int(x) for x in input().split()]
s = 0
k = 0
m = []
while s <= a + b:
	k += 1
	s += k
	m.append(k)
del m[k - 1]
d = a + b - s
p = []
for i in range(k - 2, -1, -1):
	if a >= m[i]:
		p.append(m[i])
		a -= m[i]
		del m[i]
print(len(p))
print(*p, sep=' ')
print(len(m))
print(*m, sep=' ')


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


(a, b) = input().split()
a = int(a)
b = int(b)
v = 0
l = []
k = 0
s = 0
while s <= a + b:
	k += 1
	s += k
	l.append(k)
del l[-1]
m = []
for i in range(k - 2, -1, -1):
	if a >= l[i]:
		a -= l[i]
		m.append(l[i])
		del l[i]
print(len(m))
print(*m)
print(len(l))
print(*l)


(a, b) = map(int, input().split())
if a <= b:
	l = 0
	r = a + 1
	while r - l > 1:
		m = (l + r) // 2
		if m * (m + 1) // 2 > a:
			r = m
		else:
			l = m
	n = l
	a -= n * (n + 1) // 2
	c = 1
	N = [i + 1 for i in range(n)]
	if a > 0:
		c = n + 1 - a
		N.pop(c - 1)
		N.append(c + a)
		N[-1] = c + a
	D = []
	if a != 0:
		b -= c
		D = [c]
		n = n + 1
	n += 1
	while b >= 0:
		b -= n
		D.append(n)
		n += 1
	D.pop(-1)
	print(len(N))
	if len(N) != 0:
		print(*N)
	print(len(D))
	if len(D) != 0:
		print(*D)
else:
	c = a
	a = b
	b = c
	l = 0
	r = a + 1
	while r - l > 1:
		m = (l + r) // 2
		if m * (m + 1) // 2 > a:
			r = m
		else:
			l = m
	n = l
	a -= n * (n + 1) // 2
	c = 1
	N = [i + 1 for i in range(n)]
	if a > 0:
		c = n + 1 - a
		N.pop(c - 1)
		N.append(c + a)
		N[-1] = c + a
	D = []
	if a != 0:
		b -= c
		D = [c]
		n = n + 1
	n += 1
	while b >= 0:
		b -= n
		D.append(n)
		n += 1
	D.pop(-1)
	print(len(D))
	if len(D) != 0:
		print(*D)
	print(len(N))
	if len(N) != 0:
		print(*N)


inp = input().split()
a = int(inp[0])
b = int(inp[1])
x = 1
while (x + 1) * (x + 2) / 2 <= a + b:
	x += 1
choice_map = [False for _ in range(x)]
choice_a = []
choice_b = []
aux_a = a
aux_b = b
for _i in range(x):
	i = x - 1 - _i
	if i + 1 <= aux_a and (not choice_map[i]):
		choice_a.append(i + 1)
		aux_a -= i + 1
		choice_map[i] = True
for _i in range(x):
	i = x - 1 - _i
	if i + 1 <= aux_b and (not choice_map[i]):
		choice_b.append(i + 1)
		aux_b -= i + 1
		choice_map[i] = True
print(len(choice_a))
for i in choice_a:
	print(i, end=' ')
print('')
print(len(choice_b))
for i in choice_b:
	print(i, end=' ')
print('')


(a, b) = map(int, input().split())
e = 1
while e * (e + 1) // 2 < a + b:
	e += 1
if e * (e + 1) // 2 > a + b:
	e -= 1
use = [0] * 1000000
q = []
p = []
i = e
s = 0
while True:
	if i == 0:
		break
	if a >= s + i:
		q.append(i)
		use[i] = 1
		s += i
	else:
		a -= s
		if not a:
			break
		q.append(a)
		use[a] = 1
		break
	i -= 1
for i in range(1, e + 1):
	if not use[i]:
		p.append(i)
print(len(q))
print(*q)
print(len(p))
print(*p)


import math
(a, b) = map(int, input().split())
if b >= a:
	n = math.ceil((-1 + (1 + 8 * b) ** 0.5) / 2)
	new = n * (n + 1) // 2
	d = new - b
	barr = []
	s = set()
	for i in range(1, n + 1):
		if i == d:
			continue
		barr.append(i)
		s.add(i)
	aarr = []
	som = 0
	for i in range(1, a + 1):
		if i in s:
			continue
		som += i
		if som > a:
			break
		else:
			aarr.append(i)
	print(len(aarr))
	print(*aarr)
	print(len(barr))
	print(*barr)
else:
	n = math.ceil((-1 + (1 + 8 * a) ** 0.5) / 2)
	new = n * (n + 1) // 2
	d = new - a
	aarr = []
	s = set()
	for i in range(1, n + 1):
		if i == d:
			continue
		aarr.append(i)
		s.add(i)
	barr = []
	som = 0
	for i in range(1, b + 1):
		if i in s:
			continue
		som += i
		if som > b:
			break
		else:
			barr.append(i)
	print(len(aarr))
	print(*aarr)
	print(len(barr))
	print(*barr)


(n, m) = list(map(int, input().split()))
basis = []
day2 = []
day1 = []
day1sum = 0
iterator = 1
suma = 0
a = n + m
while suma + iterator <= a:
	basis.append(iterator)
	suma += iterator
	iterator += 1
for i in range(len(basis) - 1, -1, -1):
	if n - basis[i] >= 0:
		n -= basis[i]
		day1.append(basis[i])
	else:
		day2.append(basis[i])
print(len(day1))
print(' '.join(map(str, day1)))
print(len(day2))
print(' '.join(map(str, day2)))


def findn(a, b):
	s = a + b
	left = 0
	right = b
	while left + 1 < right:
		mid = (left + right) // 2
		if mid ** 2 + mid < 2 * s:
			left = mid
		else:
			right = mid
	if right ** 2 + right > 2 * s:
		return right - 1
	return right
flag = True
(a, b) = map(int, input().split())
if b < a:
	flag = False
	(a, b) = (b, a)
n = findn(a, b)
tmpa = []
tmpb = []
while n > 0:
	if a - n >= 0:
		a -= n
		tmpa.append(n)
	else:
		tmpb.append(n)
	n -= 1
if flag:
	print(len(tmpa))
	print(' '.join(map(str, tmpa)))
	print(len(tmpb))
	print(' '.join(map(str, tmpb)))
else:
	print(len(tmpb))
	print(' '.join(map(str, tmpb)))
	print(len(tmpa))
	print(' '.join(map(str, tmpa)))


import sys
from math import sqrt

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

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve(a, b, z1):
	l = 0
	r = a
	a *= 2
	while l < r:
		c = (l + r) // 2
		if c * (c + 1) < a:
			l = c + 1
		else:
			r = c
	x = l
	while (x + 1) * x <= a:
		x += 1
	while (x + 1) * x > a:
		x -= 1
	z = x + 1
	l = z
	r = b
	b *= 2
	while l < r:
		c = (l + r) // 2
		if (c - z + 1) * (c + z) < b:
			l = c + 1
		else:
			r = c
	x = l
	while (x - z + 1) * (x + z) <= b:
		x += 1
	while (x - z + 1) * (x + z) > b:
		x -= 1
	return ((1, z), (z, x + 1))

def main1():
	(a, b) = mints()
	best = None
	(z1, z2) = solve(a, b, False)
	if z1 != None:
		bn = z2[1] - z1[0]
		if best == None or bn > best:
			best = bn
			ba = z1
			bb = z2
			bc = None
	(z1, z2) = solve(b, a, False)
	if z1 != None:
		bn = z2[1] - z1[0]
		if best == None or bn > best:
			best = bn
			ba = z2
			bb = z1
			bc = None
	for i in range(1, int(sqrt(a)) + 5):
		if b - i < 0:
			break
		(z1, z2) = solve(a + i, b - i, False)
		if z1 != None:
			bn = z2[1] - z1[0]
			if best == None or bn > best:
				best = bn
				ba = z1
				bb = z2
				bc = (0, i)
	for i in range(1, int(sqrt(b)) + 5):
		if a - i < 0:
			break
		(z1, z2) = solve(b + i, a - i, False)
		if z1 != None:
			bn = z2[1] - z1[0]
			if best == None or bn > best:
				best = bn
				ba = z2
				ba.append(i)
				bb = z1
				bb.remove(i)
				bc = (1, i)
	ba = list(range(*ba))
	bb = list(range(*bb))
	if bc:
		if bc[0] == 0:
			ba.remove(bc[1])
			bb.append(bc[1])
		else:
			ba.append(bc[1])
			bb.remove(bc[1])
	print(len(ba))
	print(*ba)
	print(len(bb))
	print(*bb)

def main():
	(a, b) = mints()
	l = 0
	r = a + b + 1
	while l < r:
		c = (l + r) // 2
		if c * (c + 1) // 2 < a + b:
			l = c + 1
		else:
			r = c
	while l * (l + 1) // 2 < a + b:
		l += 1
	while l * (l + 1) // 2 > a + b:
		l -= 1
	z = l
	l = 0
	r = a + b + 1
	while l < r:
		c = (l + r) // 2
		if (z - c + 1) * (z + c) // 2 > a:
			l = c + 1
		else:
			r = c
	while l >= 0 and (z - l + 1) * (z + l) // 2 < a:
		l -= 1
	while (z - l + 1) * (z + l) // 2 > a:
		l += 1
	l = max(l, 0)
	rest = a - (z - l + 1) * (z + l) // 2
	ba = list(range(max(l, 1), z + 1))
	bb = list(range(1, l))
	if len(ba) != z:
		if rest != 0:
			ba.append(rest)
		if rest != 0:
			bb.remove(rest)
	print(len(ba))
	print(*ba)
	print(len(bb))
	print(*bb)
main()


import math
(a, b) = (int(x) for x in input().split())
p = []
q = []
c = int((-1 + math.sqrt(1 + 8 * (a + b))) // 2)
d = list(range(1, c + 1))
if b < a:
	if b == 0:
		p = d
	else:
		q.append(min(b, c))
		d.pop(d.index(q[0]))
		while True:
			if b - sum(q) > 0:
				q.append(min(d[-1], b - sum(q)))
				d.pop(d.index(q[-1]))
			else:
				break
		p = d
elif a <= b:
	if a == 0:
		q = d
	else:
		p.append(min(a, c))
		d.pop(d.index(p[0]))
		while True:
			if a - sum(p) > 0:
				p.append(min(d[-1], a - sum(p)))
				d.pop(d.index(p[-1]))
			else:
				break
		q = d
print(len(p))
print(' '.join(map(str, p)))
print(len(q))
print(' '.join(map(str, q)))


def count_2_days(a, b):
	sumi = a + b
	sum_ = 0
	numbers = []
	for i in range(1, sumi + 1):
		if sum_ + 2 * i + 1 <= sumi:
			sum_ += i
			numbers.append(i)
		elif sum_ + 2 * i + 1 > sumi:
			numbers.append(sumi - sum_)
			break
		elif sum_ + i == sumi:
			numbers.append(i)
			sum_ += i
			break
		elif i == sumi:
			numbers.append(i)
			sum_ += i
			break
	new_a = a
	new_b = b
	note_a = []
	note_b = []
	for item in range(len(numbers) - 1, -1, -1):
		if numbers[item] <= new_a:
			note_a.append(numbers[item])
			new_a -= numbers[item]
		elif numbers[item] <= new_b:
			note_b.append(numbers[item])
		else:
			note_a.append(numbers[item] - 1)
			new_a -= numbers[item] - 1
	print(len(note_a))
	print(*note_a)
	print(len(note_b))
	print(*note_b)
(a, b) = map(int, input().split())
count_2_days(a, b)


import math

def sum(n):
	return n * (n + 1) / 2
(a, b) = map(int, input().split())
x = a + b
n = math.ceil(math.sqrt(2 * x))
while sum(n) > x:
	n -= 1
va = []
vb = []
for i in range(n, 0, -1):
	if i <= a:
		a -= i
		va.append(i)
	else:
		b -= i
		vb.append(i)
va.sort()
vb.sort()
print(len(va))
for e in va:
	print(e, end=' ')
print('\n' + str(len(vb)))
for e in vb:
	print(e, end=' ')


capacity = [int(i) for i in input().split()]
x = 0
while x * (x + 1) // 2 <= sum(capacity):
	x += 1
x -= 1
reading_list = [[], []]
cur_size = [0, 0]
for i in range(x, 0, -1):
	for j in range(2):
		if cur_size[j] + i <= capacity[j]:
			cur_size[j] += i
			reading_list[j].append(i)
			break
for j in range(2):
	print(len(reading_list[j]))
	print(*reading_list[j])


(a, b) = map(int, input().split())
c = a + b
k = 1
s = 0
while s + k <= c:
	s += k
	k += 1
x = []
border = -1
d = -1
for i in range(k - 1, 0, -1):
	if i <= a:
		a -= i
		x.append(str(i))
	elif i > a and a != 0:
		d = a
		x.append(str(a))
		border = i
		break
	elif a == 0:
		border = i
		break
y = []
for i in range(border, 0, -1):
	if i != d:
		y.append(str(i))
print(len(x))
if len(x) != 0:
	print(' '.join(x))
print(len(y))
if len(y) != 0:
	print(' '.join(y))


def print_result(arr):
	print(len(arr))
	for num in arr:
		print(num, end=' ')
	print()
arr = [int(x) for x in input().split()]
(a, b) = (arr[0], arr[1])
s = a + b
used = 0
j = 1
while used + j <= s:
	used += j
	j += 1
j -= 1
(A, B) = ([], [])
for i in range(j, 0, -1):
	if a >= i:
		A.append(i)
		a -= i
	else:
		assert b >= i
		B.append(i)
		b -= i
print_result(A)
print_result(B)


from math import *
from array import array

def floor_sqrt(x):
	(l, r) = (0, x + 1)
	while r - l > 1:
		temp = r + l >> 1
		if temp ** 2 <= x:
			l = temp
		else:
			r = temp
	return l

def main():
	(a, b) = [int(x) for x in input().split()]
	swap = False
	if a > b:
		swap = True
		(a, b) = (b, a)
	n = floor_sqrt((a + b << 3) + 1) - 1 >> 1
	used = array('b', [False for i in range(n + 1)])
	k = n
	while a > 0:
		while k > a:
			k -= 1
			assert k > 0
		a -= k
		used[k] = True
		k -= 1
	assert a is 0
	(a1, b1) = ([], [])
	for x in range(1, n + 1):
		if used[x]:
			a1.append(x)
		else:
			b1.append(x)
	if swap:
		(a1, b1) = (b1, a1)
	print(len(a1))
	for x in a1:
		print(x, end=' ')
	print()
	print(len(b1))
	for x in b1:
		print(x, end=' ')
main()


(a, b) = map(int, input().split())
s = a + b
best = 0
for i in range(1, s + 1):
	if i * (i + 1) // 2 <= s:
		best = i
	else:
		break
save_best = best
first_day = set()
second_day = set()
while a != 0 and best != 0:
	nxt = min(a, best)
	best -= 1
	first_day.add(nxt)
	a -= nxt
for i in range(1, save_best + 1):
	if i not in first_day:
		second_day.add(i)
print(len(first_day))
print(' '.join(map(str, sorted(first_day))))
print(len(second_day))
print(' '.join(map(str, sorted(second_day))))


(a, b) = map(int, input().split())
n = None
for i in range(10 ** 5):
	if i * (i + 1) <= (a + b) * 2:
		n = i
	else:
		break
s1 = 0
a1 = []
a2 = []
for i in range(1, n + 1):
	if s1 + i <= a:
		a1.append(i)
		s1 += i
	elif s1 < a:
		x = s1 + i - a
		a1.remove(x)
		a1.append(i)
		a2.append(x)
		s1 = a
	else:
		a2.append(i)
print(len(a1))
print(*a1)
print(len(a2))
print(*a2)


(a, b) = map(int, input().split())
t = a
x = a + b
i = 0
while i * (i + 1) // 2 <= x:
	i += 1
n = i - 1
x = []
y = []
k = []
i = 0
p = 0
while i < n:
	k += [i + 1]
	i += 1
i = n - 1
h = 0
while i > -1:
	if a >= k[i]:
		a -= k[i]
		x += [k[i]]
		h += 1
	else:
		if a != 0:
			p = 1
			x += [k[a - 1]]
			del k[a - 1]
			h += 1
		break
	i -= 1
if p == 1:
	i -= 1
while i > -1:
	y += [k[i]]
	i -= 1
print(h)
for i in x:
	print(i, end=' ')
if t != 0:
	print()
print(n - h)
for i in y:
	print(i, end=' ')


from sys import exit

def f1(a):
	d = int((1 + 8 * a) ** 0.5)
	fst = (d - 1) // 2
	if fst != 0:
		ost = a - fst * (fst + 1) // 2
		p = ost // fst
		ls1 = p + 1
		lf1 = p + fst - ost % fst
		ls2 = lf1 + 2
		lf2 = fst + p + 1
		return (ls1, lf1, ls2, lf2)
	else:
		return (1, 0, 1, 0)

def f2(poss):
	for pos in poss:
		for i in range(pos[0], pos[1] + 1):
			print(i, end=' ')
	print()

def main():
	(a, b) = map(int, input().split())
	(ls1, lf1, ls2, lf2) = f1(a)
	print(lf1 - ls1 + 1 + lf2 - ls2 + 1)
	f2(((ls1, lf1), (ls2, lf2)))
	s = 0
	i = 1
	arr = []
	while True:
		if ls1 <= i <= lf1:
			i = lf1
		elif ls2 <= i <= lf2:
			i = lf2
		elif s + i <= b:
			s += i
			arr.append(str(i))
		else:
			break
		i += 1
	print(len(arr))
	print(' '.join(arr))
main()


(a, b) = [int(i) for i in input().split()]
x = 0
while x * (x + 1) // 2 <= a + b:
	x += 1
x -= 1
Alist = []
Blist = []
curA = 0
curB = 0
for i in range(x, 0, -1):
	if curA + i <= a:
		curA += i
		Alist.append(i)
	elif curB + i <= b:
		curB += i
		Blist.append(i)
print(len(Alist))
print(*Alist)
print(len(Blist))
print(*Blist)


def shours(x):
	return x * (1 + x) // 2

def solver(k):
	if k in {0, 1}:
		return k
	a = 0
	b = k
	while b - a != 1:
		m = (a + b) // 2
		if shours(m) > k:
			b = m
		else:
			a = m
	return a
(a, b) = [int(x) for x in input().split()]
x = []
y = []
for text in list(range(solver(a + b), 0, -1)):
	if a >= text:
		a -= text
		x += [text]
	else:
		y += [text]
print(len(x))
print(*x)
print(len(y))
print(*y)


def Binary(s):
	L = 0
	R = s + 1
	while L <= R - 1:
		c = (L + R) // 2
		x = (1 + c) * c // 2
		if s == x:
			return c
		elif x < s:
			L = c + 1
		else:
			R = c
	return L - 1
(a, b) = map(int, input().split())
s = a + b
C = list(range(1, Binary(s) + 1))
A = []
B = []
for i in range(len(C) - 1, -1, -1):
	n = C[i]
	if a - C[i] >= 0:
		a -= C[i]
		A.append(C[i])
	else:
		B.append(C[i])
print(len(A))
print(*A)
print(len(B))
print(*B)


(a, b) = map(int, input().split())
k = 1
s = 1
while s + (k + 1) <= a + b:
	k += 1
	s += k
p = []
q = []
sp = 0
use = set()
for i in range(1, k + 1)[::-1]:
	if sp + i <= a:
		p.append(i)
		sp += i
		use.add(i)
sq = 0
for i in range(1, k + 1)[::-1]:
	if not i in use:
		if sq + i <= b:
			sq += i
			q.append(i)
print(len(p))
print(*p)
print(len(q))
print(*q)


import sys, time, os
from pprint import pprint as pp
if os.environ.get('_ONPC_', False):
	stdin = open('input.txt', 'r')
	stdout = open('output.txt', 'w')
	sys.stdin = stdin
	sys.stdout = stdout
	now = time.time()
	__flag = True
else:
	__flag = False

def what(obj):
	if __flag:
		pp(obj, sys.stderr)
(a, b) = map(int, input().split())
s = a + b
n = int(((1 + s * 8) ** 0.5 - 1) / 2)
used = []
bb = []
aa = []
for i in range(n, 0, -1):
	if b >= i:
		b -= i
		bb.append(i)
	else:
		aa.append(i)
print(len(aa))
print(' '.join(map(str, aa)))
print(len(bb))
print(' '.join(map(str, bb)))
if __flag:
	stdout.close()
	stdin.close()
	print(time.time() - now, file=sys.stderr)


import math

def sumseq(k, n):
	return n * (n + k) >> 1
days = input().split(' ')
(day0, day1) = (int(days[0]), int(days[1]))
(rest0, rest1) = (day0, day1)
k = int(math.sqrt((day0 << 1) + (day1 << 1)))
if day0 + day1 < sumseq(1, k):
	k -= 1
(conspects0, conspects1) = ([], [])
for h in range(k, 0, -1):
	if h <= day0:
		conspects0.insert(0, str(h))
		day0 -= h
	elif h <= day1:
		conspects1.insert(0, str(h))
		day1 -= h
print(len(conspects0))
print(' '.join(conspects0))
print(len(conspects1))
print(' '.join(conspects1))


import math
nums = list(map(int, input().split()))
a = nums[0]
b = nums[1]
c = a + b
n = int((math.sqrt(1 + 8 * c) - 1) / 2)
konsp = []
foo = 1
for foo in range(1, n + 1):
	konsp.append(foo)
first_day = []
second_day = []
konsp.reverse()
for bar in konsp:
	if bar <= a and bar <= b:
		if a >= b:
			second_day.append(bar)
			b -= bar
		else:
			first_day.append(bar)
			a -= bar
	elif bar <= b:
		second_day.append(bar)
		b -= bar
	elif bar <= a:
		first_day.append(bar)
		a -= bar
res_first = ''
for foo in first_day:
	res_first += str(foo) + ' '
res_second = ''
for foo in second_day:
	res_second += str(foo) + ' '
print(str(len(first_day)) + '\n' + res_first)
print(str(len(second_day)) + '\n' + res_second)


import math
(a, b) = map(int, input().strip().split())
n = math.floor(-0.5 + (0.25 + 2 * (a + b)) ** 0.5)
f = []
s = []
se = set()
for i in range(n, 0, -1):
	if i <= a:
		a -= i
		f.append(i)
		se.add(i)
for i in range(n, 0, -1):
	if i <= b and i not in se:
		b -= i
		s.append(i)
print(len(f))
print(' '.join(map(str, f)))
print(len(s))
print(' '.join(map(str, s)))


import math
tr = list(map(int, input().split()))
a = tr[0]
b = tr[1]
n = (-1 + math.sqrt(1 + 8 * (a + b))) // 2
first = []
second = []
for i in range(int(n), 0, -1):
	if a >= b:
		if a >= i:
			first.append(i)
			a -= i
	elif b >= i:
		second.append(i)
		b -= i
print(len(first))
print(' '.join([str(i) for i in first]))
print(len(second))
print(' '.join([str(i) for i in second]))