def _s_u_b_s_e_t_s( n ):
stack = [0]
stack[-1] = 1
for i in range(0, len(stack)):
if stack[i] > 0:
print(stack[i], end = '\n')
while not len(stack) == 0 :
if stack[-1] < n:
stack.append(stack[-1] + 1)
else:
stack.pop()
if len(stack)!= 0:
stack[-1] += 1
for i in range(0, len(stack)):
if stack[i] > 0:
print(stack[i], end = ' ')
print()
def main():
n = int(input())
_s_u_b_s_e_t_s( n )
main()
ZGVmIF9zX3VfYl9zX2VfdF9zKCBuICk6CgogICAgc3RhY2sgPSBbMF0KCiAgICBzdGFja1stMV0gPSAxCiAgICAKICAgIGZvciBpIGluIHJhbmdlKDAsIGxlbihzdGFjaykpOgoKICAgICAgICBpZiBzdGFja1tpXSA+IDA6CgogICAgICAgICAgIHByaW50KHN0YWNrW2ldLCBlbmQgPSAnXG4nKQoKICAgIHdoaWxlIG5vdCBsZW4oc3RhY2spID09IDAgOgoKICAgICAgICBpZiBzdGFja1stMV0gPCBuOgoKICAgICAgICAgICBzdGFjay5hcHBlbmQoc3RhY2tbLTFdICsgMSkKCiAgICAgICAgZWxzZToKCiAgICAgICAgICAgc3RhY2sucG9wKCkKCiAgICAgICAgICAgaWYgbGVuKHN0YWNrKSE9IDA6CgogICAgICAgICAgICAgIHN0YWNrWy0xXSArPSAxCgoKICAgICAgICBmb3IgaSBpbiByYW5nZSgwLCBsZW4oc3RhY2spKToKCiAgICAgICAgICAgaWYgc3RhY2tbaV0gPiAwOgogICAgICAgICAgICAKICAgICAgICAgICAgICBwcmludChzdGFja1tpXSwgZW5kID0gJyAnKQoKICAgICAgICBwcmludCgpICAgICAgICAgICAgICAKCmRlZiBtYWluKCk6CgkKCW4gPSBpbnQoaW5wdXQoKSkKCQoJX3NfdV9iX3NfZV90X3MoIG4gKQogICAgCm1haW4oKSAgICA=