Petya has n integers: 1, 2, 3, ..., n. He wants to split these integers in two non-empty groups in such a way that the absolute difference of sums of integers in each group is as small as possible. 

Help Petya to split the integers. Each of n integers should be exactly in one group.


-----Input-----

The first line contains a single integer n (2 ≤ n ≤ 60 000) — the number of integers Petya has.


-----Output-----

Print the smallest possible absolute difference in the first line.

In the second line print the size of the first group, followed by the integers in that group. You can print these integers in arbitrary order. If there are multiple answers, print any of them.


-----Examples-----
Input
4

Output
0
2 1 4 

Input
2

Output
1
1 1 



-----Note-----

In the first example you have to put integers 1 and 4 in the first group, and 2 and 3 in the second. This way the sum in each group is 5, and the absolute difference is 0.

In the second example there are only two integers, and since both groups should be non-empty, you have to put one integer in the first group and one in the second. This way the absolute difference of sums of integers in each group is 1.

Difficulty: interview

Starter code:

Solutions:
n = int(input())
f = []
s = []
f1 = s1 = 0
for i in range(n, 0, -1):
	if f1 <= s1:
		f1 += i
		f.append(i)
	else:
		s1 += i
		s.append(i)
print(abs(f1 - s1))
print(len(f), *f)

#python3
# utf-8

n = int(input())

decide = list(range(1, n % 4 + 1))
n_sum = 0
first_group = []
if n % 4 == 1:
    n_sum = 1
if n % 4 == 2:
    n_sum = 1
    first_group.append(2)
if n % 4 == 3:
    n_sum = 0
    first_group.append(3)
k = n
while k > 3:
    first_group.append(k)
    first_group.append(k - 3)
    k -= 4
print(n_sum)
print(len(first_group), *first_group)


from sys import stdin as cin
from sys import stdout as cout

def main():
    n = int(cin.readline())
    if n % 4 == 0:
        print(0)
        print(n // 2, end = '')
        for i in range(n // 4):
            print('', i * 4 + 1, i * 4 + 4, end = '')
    elif n % 2 == 0:
        print(1)
        print(n // 2, end = '')
        for i in range((n - 2) // 4):
            print('', i * 4 + 1, i * 4 + 4, end = '')
        print('', n - 1)
    elif n % 4 == 1:
        print(1)
        print(n // 2, end = '')
        for i in range((n - 1) // 4):
            print('', i * 4 + 2, i * 4 + 5, end = '')
    else:
        print(0)
        print(n // 2, 3, end = '')
        for i in range((n - 3) // 4):
            print('', i * 4 + 4, i * 4 + 7, end = '')

main()


n = int(input())
s = ""
if n % 4 == 0:
  print(0)
  s += str(n // 2) + " "
  for i in range(n // 4):
    s += str(4 * i + 1) + " "
    s += str(4 * i + 4) + " "
  print(s[:-1])
elif n % 4 == 3:
  print(0)
  s += str(n // 2 + 1) + " "
  s += "1 2 "
  for i in range(n // 4):
    s += str(4 * i + 4) + " "
    s += str(4 * i + 7) + " "
  print(s[:-1])
elif n % 4 == 2:
  print(1)
  s += str(n // 2) + " 1 "
  for i in range(0, n // 4):
    s += str(4 * i + 3) + " "
    s += str(4 * i + 6) + " "
  print(s[:-1])
else:
  print(1)
  s += str(n // 2 + 1) + " 1 "
  for i in range(0, n // 4):
    s += str(4 * i + 2) + " "
    s += str(4 * i + 5) + " "
  print(s[:-1])

n = int(input())
s = sum([i for i in range(n + 1)])
print(s % 2)
ans = []
q = s // 2
for i in range(n - 1, 0, -1):
    if q >= i:
        ans = [i] + ans
        q -= i
print(len(ans), *ans)

n = int(input())

total = int(n * (n + 1) / 2)

l = []
cur = 0
if total % 2 == 0:
    print(0)
    target = total // 2
    while cur != target:
        if target - cur <= n:
            l.append(target - cur)
            break
        else:
            l.append(n)
            cur += n
            n -= 1
else:
    print(1)
    target = total // 2
    while cur != target:
        if target - cur <= n:
            l.append(target - cur)
            break
        else:
            l.append(n)
            cur += n
            n -= 1
print(len(l), end = ' ')
print(*l)

n = int(input())
# a = []
# b = []
# for i in range(1, n+1):
# 	if (i//2)%2 == 0:
# 		a.append(i)
# 	else:
# 		b.append(i)
# print(abs(sum(a) - sum(b)))
# print(len(a), ' '.join(str(x) for x in a))

l = list(range(1, n+1))
a = []
target = (n * (n+1))//4
accum = 0
for i in reversed(l):
	if accum + i <= target:
		a.append(i)
		accum += i

print(abs(accum - (n*(n+1))//2 + accum))
print(len(a), ' '.join(str(x) for x in a))


n = int(input())
ans = []
flag = 0
if n % 2:
    n -= 1
    flag = 1
if (n % 4 == 0 and not flag) or (n % 4 and flag):
    print(0)
    for i in range(n // 2):
        if i % 2 == 0:
            ans.append(i + 1)
            ans.append(n - i)
    print(len(ans), end=' ')
    for i in ans:
        print(i, end=' ')
else:
    print(1)
    for i in range(n // 2 - 1):
        if i % 2 == 0:
            if i % 2 == 0:
                ans.append(i + 1)
                ans.append(n - i)
    ans.append(n // 2 + 1)
    print(len(ans), end=' ')
    for i in ans:
        print(i, end=' ')

n=int(input())
if n%4==3:
    print(0)
    print((n-3)//2+2,end=' ')
    print(1,2,' '.join([str(i)+' '+str(i+3) for i in range(4,n-2,4)]))
elif n%4==0:
    print(0)
    print(n//2,end=' ')
    print(' '.join([str(i)+' '+str(i+3) for i in range(1,n-2,4)]))
elif n%4==1:
    print(1)
    print(n//2+1,end=' ')
    print(1,' '.join([str(i)+' '+str(i+3) for i in range(2,n-2,4)]))
elif n%4==2:
    print(1)
    print(n//2,end=' ')
    print(1,' '.join([str(i)+' '+str(i+3) for i in range(3,n-2,4)]))

n = int(input())

if n % 4 == 0:
    print(0)
    data = []
    for i in range(1, n + 1, 4):
        data.append(str(i) + ' ' + str(i + 3))
elif n % 4 == 3:
    print(0)
    data = []
    for i in range(4, n + 1, 4):
        data.append(str(i) + ' ' + str(i + 3))
    data.append('1 2')
elif n % 4 == 1:
    print(1)
    data = []
    for i in range(2, n + 1, 4):
        data.append(str(i) + ' ' + str(i + 3))
    data.append('1')
else:
    print(1)
    data = []
    for i in range(3, n + 1, 4):
        data.append(str(i) + ' ' + str(i + 3))
    data.append('1')
data = ' '.join(data).split()
print(len(data), ' '.join(data))


# cook your dish here
n = int(input().strip())
if n%2==1:
    print(((n+1)//2)%2)
    print((n+1)//2,end=" ")
    i = 1
    while i <= n:
        if i<n:
            print(i,i+1,end=" ")
        else:
            print(i,end=" ")
        i+=4
    print()
else:
    print((n//2)%2)
    print(n//2,1,end=" ")
    i=4
    while i <= n:
        if i<n:
            print(i,i+1,end=" ")
        else:
            print(i,end=" ")
        i+=4
    print()
    

import sys

lines = []
for line in sys.stdin:
    lines.append(line)

n = int(lines[0].rstrip("\r\n\t "))

in_a = []
a_size = 0
a_sum = 0
b_sum = 0
for x in range(n, 0, -1):
    if a_sum <= b_sum:
        in_a.append(str(x))
        a_size += 1
        a_sum += x
    else:
        b_sum += x

print(("{}\n{} {}".format(
    abs(a_sum - b_sum),
    a_size,
    " ".join(in_a)
)))


n = int(input())
if n % 4 == 0:
    print(0)
    print(n//2,end=" ")
    step = 0
    for i in range(1,n+1,2):
        print(i+step,end=" ")
        step = 1 - step
elif n % 4 == 3:
    print(0)
    print(n//2,end=" ")
    step = 1
    for i in range(2,n+1,2):
        print(i+step,end=" ")
        step = 1 - step
else:
    print(1)
    if n % 4 == 2:
        print(n//2,end=" ")
        step = 0
        for i in range(1,n+1,2):
            print(i+step,end=" ")
            step = 1 - step
    else:
        print(n//2,end=" ")
        step = 1
        for i in range(2,n+1,2):
            print(i+step,end=" ")
            step = 1 - step
    


# IAWT
n = int(input())
s = (n + 1) * n // 4
a = []
for i in range(n, 0, -1):
    if (s >= i):
        a.append(i)
        s -= i

print(abs( ((n+1)*n//2 - sum(a)) - sum(a)))
print(len(a), end = ' ')
for x in a: print(x, end = ' ')
    


n = int(input())
whSumv = (n * (n+1)) // 2
sumv = 0
ans = []
for i in reversed(range(1, n+1)):
	if sumv + i <= whSumv//2:
		sumv += i
		ans += [i]
print(abs(whSumv-sumv-sumv))
print(len(ans), ' '.join(map(str, ans)))

n = int(input())
a = [int(i) for i in range(1, n + 1)]
a.reverse()
left = 0
right = 0
l = []
r = []
for i in a:
    if left < right:
        left += i
        l.append(i)
    else:
        right += i
        r.append(i)
print(abs(left - right))
l.sort()
r.sort()
ans = [l, r]
ans.sort()
print(len(ans[0]), " ".join(str(i) for i in ans[0]))

import sys

n = int(input())

##I = [i for i in range(1, n + 1)]
##
##levi = 0
##desni = len(I) - 1
##
##prvi = set()
##drugi = set()
##
##while desni - levi >= 3:
##    prvi.add(I[levi])
##    prvi.add(I[desni])
##    drugi.add(I[levi+1])
##    drugi.add(I[desni-1])
##    levi += 2
##    desni -= 2
##
##if desni - levi == 2:
##    prvi.add(I[levi])
##    prvi.add(I[levi+1])
##    drugi.add(I[desni])
##elif desni - levi == 1:
##    prvi.add(I[levi])
##    drugi.add(I[levi+1])
##elif desni - levi == 0:
##    prvi.add(I[levi])
##else:
##    pass
##
##print(abs(sum(prvi) - sum(drugi)))
##print(str(len(prvi)) + ' ' + ' '.join(map(str, prvi)))

vseh = n*(n+1)//2

hit = vseh//2

def posible(hit, n):
    nums = set()
    maks = n
    while hit > 0:
        if maks > hit:
            maks = hit 
        hit -= maks
        nums.add(maks)
        maks -= 1
        if maks <= 0:
            break
    return nums

#print(vseh)
for k in range(5):
    A = posible(hit-k, n)
    x = vseh - sum(A)
    print(abs(x - sum(A)))
    print(str(len(A)) + ' ' + ' '.join(map(str, A)))
    return
        


n=int(input())
d=n
for i in range(n):d+=i
h=d>>1
a=[]
t=n
s=0
while h:
    if t<=h:h-=t;s+=t;a.append(t)
    t=min(t-1,h)
print(abs(d-s*2))
print(len(a),end=' ')
print(*a)

n = int(input())
l = range(1,n+1)
s = ((n+1)*n)//2
print(s%2)
t = 0
tp = []
pt = -1
while not ((s//2 - t) in l and (s//2 - t) not in tp):
  t += l[pt]
  tp.append(l[pt])
  pt -= 1
tp.append(s//2-t)
print(len(tp), ' '.join(str(i) for i in tp))

n = int(input())
sum = (1 + n) * n // 2
print (sum % 2)
a = sum // 2
ans = []
while a:
	if a > n:
		ans += [n]
		a -= n
		n -= 1
	else:
		ans += [a]
		a = 0

print (len(ans), end=" ")

for i in ans:
	print (i, end=" ")

n=int(input())
a=[0 for i in range(n+1)] 
# a[-1]=set 

if n%2==0:
    a[n]=1
    for i in range(n-1,0,-1):
        if i%2==0:
            a[i]=a[i+1]
        else:
            a[i]=1-a[i+1]
else:
    a[n]=1
    for i in range(n-1,0,-1):
        if i%2==1:
            a[i]=a[i+1]
        else:
            a[i]=1-a[i+1]
b=[]
c=[]
sb=0
sc=0
for i in range(1,n+1):
    if a[i]==0:
        b.append(i)
        sb+=i
    else:
        c.append(i)
        sc+=i
print(abs(sb-sc))
print(len(c),end=" ")
for i in c:
    print(i,end=" ")
print()    
        




n = int(input())
def getg(n):
    if n%4==0:
        return (0, list(range(n//4+1, 3*n//4+1)))
    elif n%4==1:
        return (1, [1]+[x+1 for x in getg(n-1)[1]])
    elif n%4==2:
        return (1, getg(n-2)[1]+[n-1])
    elif n%4==3:
        return (0, [1]+[x+1 for x in getg(n-1)[1]])
g = getg(n)
print(g[0])
print(str(len(g[1])) + ' ' + ' '.join(str(x) for x in g[1]))


from collections import Counter
n=int(input())
z=0
for i in range(n+1):
    z=z+i
print(z%2)
z=3
s=1
a={1}
for i in range(3,n+1):
    d=(z+i)//2-s
    if d in a:
        a.remove(d)
        a.add(i)
    else:
        a.add(d)
a=list(a)
a.sort()
print(len(a),*a)



n = int(input())

res_list = []

desired_sum = (n * (n + 1) // 2)
s = 0

for j in range(n, 0, -1):
    if 2 * (s + j) <= desired_sum:
        s += j
        res_list += [j]

print(desired_sum - 2 * s)
print(str(len(res_list)), " ".join(map(str, res_list)))


n = int(input())
sm = (n * (n + 1)) // 2
arr = []
tempsm = 0
for i in range(n, 0, -1):
    if(tempsm + i <= (sm + 1) // 2):
        tempsm +=i
        arr.append(i)
print(int(abs(2 * sum(arr) - sm)))
print(len(arr))
for i in arr:
        print(i, end=' ')