#import <stdio.h>
#define M 1000000007
typedef long long INT;
INT fa(INT n, INT val){
    return (n==1)? (val%M) : fa(n-1,((n%M)*(val%M)%M));
}
INT fact(INT n){
    return fa(n,1);
}

int main(){
    INT n,m;
    scanf("%lld %lld",&n,&m);
    if (n==m) {
        printf("%lld",2*fact(n)*fact(n)%M);
    } else if (n-m==1||n-m==-1) {
        printf("%lld",fact(n)*fact(m)%M);
    } else {
        puts("0");
    }
}

; ModuleID = '/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_760/source.m'
source_filename = "/data/TheStack_IR/OJ_Samples/Collated/ObjectiveC/Source_760/source.m"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@.str = private unnamed_addr constant [10 x i8] c"%lld %lld\00", align 1
@.str.1 = private unnamed_addr constant [5 x i8] c"%lld\00", align 1
@.str.2 = private unnamed_addr constant [2 x i8] c"0\00", align 1

; Function Attrs: minsize nofree norecurse nosync nounwind optsize memory(none) uwtable
define dso_local i64 @fa(i64 noundef %n, i64 noundef %val) local_unnamed_addr #0 {
entry:
  br label %tailrecurse

tailrecurse:                                      ; preds = %cond.false, %entry
  %n.tr = phi i64 [ %n, %entry ], [ %sub, %cond.false ]
  %val.tr.in = phi i64 [ %val, %entry ], [ %mul, %cond.false ]
  %val.tr = srem i64 %val.tr.in, 1000000007
  %cmp = icmp eq i64 %n.tr, 1
  br i1 %cmp, label %cond.true, label %cond.false

cond.true:                                        ; preds = %tailrecurse
  ret i64 %val.tr

cond.false:                                       ; preds = %tailrecurse
  %sub = add nsw i64 %n.tr, -1
  %rem1 = srem i64 %n.tr, 1000000007
  %mul = mul nsw i64 %val.tr, %rem1
  br label %tailrecurse
}

; Function Attrs: minsize nofree norecurse nosync nounwind optsize memory(none) uwtable
define dso_local i64 @fact(i64 noundef %n) local_unnamed_addr #0 {
entry:
  %call = tail call i64 @fa(i64 noundef %n, i64 noundef 1) #4, !range !5
  ret i64 %call
}

; Function Attrs: minsize nofree nounwind optsize uwtable
define dso_local i32 @main() local_unnamed_addr #1 {
entry:
  %n = alloca i64, align 8
  %m = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %n) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %m) #5
  %call = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str, ptr noundef nonnull %n, ptr noundef nonnull %m) #4
  %0 = load i64, ptr %n, align 8, !tbaa !6
  %1 = load i64, ptr %m, align 8, !tbaa !6
  %cmp = icmp eq i64 %0, %1
  br i1 %cmp, label %if.then, label %if.else

if.then:                                          ; preds = %entry
  %call1 = call i64 @fact(i64 noundef %0) #4, !range !5
  %mul = shl nsw i64 %call1, 1
  %mul3 = mul nsw i64 %mul, %call1
  %rem = srem i64 %mul3, 1000000007
  %call4 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %rem) #4
  br label %if.end16

if.else:                                          ; preds = %entry
  %sub = sub nsw i64 %0, %1
  switch i64 %sub, label %if.else14 [
    i64 1, label %if.then8
    i64 -1, label %if.then8
  ]

if.then8:                                         ; preds = %if.else, %if.else
  %call9 = call i64 @fact(i64 noundef %0) #4, !range !5
  %call10 = call i64 @fact(i64 noundef %1) #4, !range !5
  %mul11 = mul nsw i64 %call10, %call9
  %rem12 = srem i64 %mul11, 1000000007
  %call13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i64 noundef %rem12) #4
  br label %if.end16

if.else14:                                        ; preds = %if.else
  %call15 = call i32 @puts(ptr noundef nonnull dereferenceable(1) @.str.2) #4
  br label %if.end16

if.end16:                                         ; preds = %if.then8, %if.else14, %if.then
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %m) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %n) #5
  ret i32 0
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #2

; Function Attrs: minsize nofree nounwind optsize
declare noundef i32 @__isoc99_scanf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: minsize nofree nounwind optsize
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #3

; Function Attrs: minsize nofree nounwind optsize
declare noundef i32 @puts(ptr nocapture noundef readonly) local_unnamed_addr #3

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #2

attributes #0 = { minsize nofree norecurse nosync nounwind optsize memory(none) uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { minsize nofree nounwind optsize uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { minsize nofree nounwind optsize "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #4 = { minsize optsize }
attributes #5 = { nounwind }

!llvm.linker.options = !{}
!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"Ubuntu clang version 18.0.0 (++20231007042255+8abb2ace888b-1~exp1~20231007042414.1230)"}
!5 = !{i64 -1000000006, i64 1000000007}
!6 = !{!7, !7, i64 0}
!7 = !{!"long long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
