program main implicit none integer*8::n,f(0:1,0:560,0:560),i,j,k,ans integer*8,parameter::mo=1000000007 read*,n do i=0,n do j=0,n f(0,i,j)=0 end do end do f(0,0,0)=1 block integer::cur,ne do i=1,n cur=mod(i-1,2) ne=mod(cur+1,2) do j=0,j do k=0,n f(ne,j,k)=0 end do end do do j=0,n do k=0,n if(f(cur,j,k)==0)cycle f(ne,j,k)=mod(f(ne,j,k)+f(cur,j,k)*j*j+f(cur,j,k)*k*(k-1)+f(cur,j,k)*k*j*2,mo) f(ne,j+1,k)=mod(f(ne,j+1,k)+f(cur,j,k),mo) f(ne,j,k+1)=mod(f(ne,j,k+1)+f(cur,j,k)*(j+k)*2,mo) f(ne,j,k+2)=mod(f(ne,j,k+2)+f(cur,j,k),mo) if(k>0)f(ne,j+1,k-1)=mod(f(ne,j+1,k-1)+f(cur,j,k)*k,mo) end do end do end do end block ans=0 do i=1,n ans=mod(ans+f(mod(n,2),i,0),mo) end do print*,ans end program