local n,m=io.read("n","n")
if math.abs(n-m)>=2 then
    print(0)
else
    local dog=1
    for i=1,n do
        dog=dog*i%1000000007
    end
    local ape=1
    for i=1,m do
        ape=ape*i%1000000007
    end
    print(n==m and 2*dog*ape%1000000007 or dog*ape%1000000007)
end