import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

N abs(N)(N a) {
  return (a < 0 ? -1 : 1) * a;
}

enum MOD = 10L^^9 + 7;

long fact(long n) {
  if (n <= 1) {
    return 1;
  } else {
    return n * fact(n - 1) % MOD;
  }
}

void main() {
  long[] NM = readln.chomp.split.to!(long[]);
  long N = NM[0],
       M = NM[1];

  if (N == M || abs(N - M) == 1) {
    long k = 1;
    if (N == M) {
      k = 2;
    }
    writeln(k * fact(N) * fact(M) % MOD);
  } else {
    writeln(0);
  }
}
