n=input() def f(m): x=[];l=len(m) if l==n:print" ".join(`m`[1::3]) for t in m:x+=[t,t-l,t+l];l-=1 for i in set(range(n))-set(x):f(m+[i]) f([])