import sys s=sys.stdin.readline() n=int(s[1:])+1 T=[0]*n q=[1] d=lambda z:d(T[z])+[z]if z else[] for x in q: a=[];z=x while z: y=x+z if y