import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    foreach(n;stdin.byLine().map!(to!int).array().until(0).array())
    {
        auto m = new int[][](n,n);
        int x=n/2, y=x+1;
        m[y][x]=1;
        foreach(i;2..n*n+1)
        {
            x=(x+1)%n,y=(y+1)%n;
            while(m[y][x]!=0) x=(x-1+n)%n,y=(y+1)%n;
            m[y][x]=i;
        }
        m.map!(a=>a.map!(v=>format("%4d",v)).join("")).join("\n").writeln();
    }
}