#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"def fact(n):\n"
"  v = 1\n"
"  for i in range(2, n + 1):\n"
"    v = v * i % 1000000007\n"
"  return v\n"
"\n"
"n, m = map(int, input().split())\n"
"if abs(n - m) > 1:\n"
"  print('0')\n"
"elif n == m:\n"
"  print(2 * fact(n) * fact(m) % 1000000007)\n"
"else:\n"
"  print(fact(n) * fact(m) % 1000000007)\n"
"\"";
  system(s);
  return 0;
}            