{*******************************************}
{* Program name: checker *}
{* Input file: checker.in *}
{* Output file: checker.out *}
{* Date: 2008.10.22 *}
{* Programmer: Peng Bo *}
{*******************************************}
program checker;
type
sz=array[1..14]of byte;
s1=array[1..14]of boolean;
s2=array[-13..13]of boolean;
s3=array[2..28]of boolean;
var
s:sz;
a:s1;
b:s2;
c:s3;
n:byte;
g:longint;
f:text;
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure main(x:byte);
var
i:byte;
{--------------------------}
procedure op;
var
i:byte;
begin
inc(g);
for i:=1 to (n-1) do
write(f,s[i],' ');
writeln(f,s[n]);
end;{op}
{--------------------------}
begin
for i:=1 to n do
if a[i] and b[x-i] and c[x+i]
then
begin
s[x]:=i;
a[i]:=false;
b[x-i]:=false;
c[x+i]:=false;
if x<n
then
main(x+1)
else
if g<3
then
op
else
inc(g);
a[i]:=true;
b[x-i]:=true;
c[x+i]:=true;
end;
end;{main}
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
procedure cs;
var
i:byte;
begin
for i:=1 to n do
a[i]:=true;
for i:=2 to (2*n) do
c[i]:=true;
for i:=0 to (2*n-2) do
b[i-n+1]:=true;
g:=0;
end;{cs}
{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
begin
assign(f,'checker.in');
reset(f);
read(f,n);
close(f);
{===========}
cs;
{===========}
assign(f,'checker.out');
rewrite(f);
{===========}
main(1);
{===========}
write(f,g);
close(f);
end.