import qualified Data.ByteString.Char8 as B
import Data.Maybe
main=print.solve.map(fst.fromJust.B.readInt).B.words=<<B.getLine
m=1000000007
solve(a:b:_)
 |d<1=2*p`mod`m
 |d<2=i*p`mod`m
 |otherwise=0
 where
  (i,j)=if a>b then(a,b)else(b,a)
  d=i-j
  p=f j^2
f 0=1
f n=n*f(n-1)`mod`m