implicit none
integer(8) :: n,m,i,kai,modu,ans
read(5,*) n,m
kai=1
ans=1
modu=10**9+7

do i=1,min(n,m)
  kai=mod(kai*i,modu)
enddo

ans=mod(kai**2,modu)

if (n==m) then
  write(6,"(i0)") mod(ans*2,modu)
else if  (abs(n-m)==1) then
  write(6,"(i0)") mod(ans*max(m,n),modu)
else 
  write(6,"(i0)") 0
endif
end