program lecsychny_perebir; {$apptype console} var ii,kt,n,i,k,j:integer; x:array [0..100] of char; t:char; function next:boolean; var k,j:integer; temp:char; found:boolean; begin i:=n; found:=false; while (not found)and(i>1)do begin found:=x[i-1]x[j+1] then begin t:=x[j];x[j]:=x[j+1];x[j+1]:=t;end; for i:=1 to n do write(x[i]); writeln; k:=1; while next do begin for i:=1 to n do write(x[i]); writeln; k:=k+1; end; end; close(input); close(output); end.