procedure solve(dep,pre:integer); var i:integer; begin if dep=k+1 then begin writeln(s);exit; end; for i:=1 to n do if (not used[i]) and (i>pre) then begin s:=s+chr(i+ord(''0''));used[i]:=true; solve(dep+1,i); s:=copy(s,1,length(s)-1); used[i]:=false; end; end;