program diverta_city
  integer :: n, i, j
  integer(8), dimension(10) :: a = (/0,1,2,4,7,12,20,29,38,52/), f = 0
  read(*,*) n
  f(3) = 1
  do i = 4, n
    f(i) = f(i-1)*(a(i-1)+a(i-2)+1)
  end do
  do i = 1, n
    do j = 1, n
      if (i == j) then
        write(*,'(i0,x)',advance='no') 0
        cycle
      end if
      write(*,'(i0,x)',advance='no') f(max(i,j))*a(min(i,j)+1)+1
    end do
    write(*,*)
  end do
end program diverta_city