r=function(a,y,z,b){if(y--)for(var x=0;x<n;x++)z&(c=(1|1<<y+9)<<x)|b&(d=1<<9+x-y)||r(a?a+" "+x:a+x,y,z|c,b|d) else print(a)} r("",n=readline())
Note that non-ascii characters in the above source code will be escaped (such as \x9f).
download
return to the top page