program EmberAsh;
var
n,i:longint;
BEGIN
assign(input,'tianshu.in');reset(input);
assign(output,'tianshu.out');rewrite(output);
readln(n);
if n=1 then
writeln('NO');
if n=2 then
begin
writeln('1 2');
writeln('4 3');
end;
if n=3 then
writeln('NO');
if n=4 then
begin
writeln('1 2 11 12');
writeln('4 9 8 5');
writeln('7 10 3 14');
writeln('6 13 16 15');
end;
if n=5 then
begin
writeln('1 6 13 10 9');
writeln('2 17 24 19 22');
writeln('3 14 5 12 25');
writeln('4 15 8 11 18');
writeln('7 16 21 20 23');
end;
if n=6 then
writeln('NO');
if n=7 then
writeln('NO');
if n=8 then
writeln('NO');
if n=9 then
writeln('NO');
if n=10 then
writeln('NO');
close(input);
close(output);
END.