program ex;
type
ss=array[-14..26]of integer;
sz=array[1..13]of integer;
var
f1,f2:text;
a:sz;
b,c,d:ss;
j,k:integer;
n,t:integer;
step:integer;
procedure init;
begin
assign(f1,'checker.in');
assign(f2,'checker.out');
reset(f1);
rewrite(f2);
readln(f1,n);
end;
procedure try(step:integer);
var
j:integer;
begin
for j:=1 to n do
if (b[j]=0) and (c[step+j]=0) and (d[step-j]=0) then
begin
a[step]:=j;
b[j]:=1;
c[step+j]:=1;
d[step-j]:=1;
if step<n then try(step+1)
else begin
inc(t);
if t<=3 then
begin
for k:=1 to n do write(f2,a[k],' ');
writeln(f2);
end;
end;
b[j]:=0;
c[step+j]:=0;
d[step-j]:=0;
end;
end;
begin
init;
for k:=-14 to 26 do
begin
b[k]:=0;
c[k]:=0;
d[k]:=0;
end;
try(1);
writeln(f2,t);
close(f1);
close(f2);
end.