{$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q-,R-,S+,T-,V+,X+,Y+} {$M 16384,0,655360} {$A+,B-,D+,E+,F-,G-,I+,L+,N-,O-,P-,Q-,R-,S+,T-,V+,X+,Y+} {$M 16384,0,655360} program tura2; var s:array[1..100] of integer; K,p,n: integer; procedure vpered; begin s[k]:=p; inc(k); p:=1; end; function mona: boolean; var f: boolean;i: integer; begin f:=true; for i:=1 to k-1 do if s[i]=p then begin f:=false; break; end; mona:=f; end; procedure nazad; begin dec(k); if k<1 then halt; p:=s[k]+1; if p>n then nazad; end; procedure vivid; var i: integer; begin for i:=1 to k-1 do write(s[i]); writeln; end; begin writeln; writeln('‚¢¥¤÷âì p®§¬÷p­÷áâì n'); readln(n); s[1]:=1; k:=2; p:=1; while k>0 do begin if mona then begin vpered;if k>n then begin vivid; nazad; end end else begin inc(p); if p>n then nazad;end; end; end.