integer(8)::a(9)=[1,2,4,7,12,20,29,38,52],f(10)=0
read(*,*)n
f(3)=1
do i=4,n
 f(i)=f(i-1)*(a(i-2)+a(i-3)+1)
enddo
do i=1,n
 do j=1,n
  write(*,*)merge(0_8,f(max(i,j))*a(min(i,j))+1,i==j)
 enddo
enddo
end