using System;
using System.Collections.Generic;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("3");
//001 002 003
//008 009 004
//007 006 005
}
else if (InputPattern == "Input2") {
WillReturn.Add("4");
//001 002 003 004
//012 013 014 005
//011 016 015 006
//010 009 008 007
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
int N = int.Parse(InputList[0]);
int UB = N - 1;
int[,] BanArr = new int[UB + 1, UB + 1];
int CurrX = 0, CurrY = 0;
int VisitedCnt = 0;
//0が右向き
//1が下向き
//2が左向き
//3が上向き
int Muki = 0;
while (true) {
BanArr[CurrX, CurrY] = ++VisitedCnt;
if (VisitedCnt == (UB + 1) * (UB + 1)) break;
//次のマスに進む
while (true) {
int HeniX, HeniY;
DeriveHeni(Muki, out HeniX, out HeniY);
int NewX = CurrX + HeniX;
int NewY = CurrY + HeniY;
if (NewX < 0 || UB < NewX
|| NewY < 0 || UB < NewY
|| BanArr[NewX, NewY] != 0) {
Muki = (Muki + 1) % 4;
continue;
}
CurrX = NewX; CurrY = NewY;
break;
}
}
var sb = new System.Text.StringBuilder();
for (int Y = 0; Y <= UB; Y++) {
for (int X = 0; X <= UB; X++) {
if (X > 0) sb.Append(' ');
sb.Append(BanArr[X, Y].ToString().PadLeft(3, '0'));
}
sb.AppendLine();
}
Console.Write(sb.ToString());
}
//向きを引数として、変位をセット
static void DeriveHeni(int pMuki, out int pHeniX, out int pHeniY)
{
pHeniX = pHeniY = -1;
if (pMuki == 0) { pHeniX = 1; pHeniY = 0; };
if (pMuki == 1) { pHeniX = 0; pHeniY = -1; };
if (pMuki == 2) { pHeniX = -1; pHeniY = 0; };
if (pMuki == 3) { pHeniX = 0; pHeniY = 1; };
}
}