#include using namespace std; typedef unsigned long long ll; const int mod = 1e9 + 7; ll a,b; int main() { scanf("%llu %llu",&a,&b); ll ans = 0; ans += 2ll * a % mod * b % mod + a % mod + b % mod + 1ll; ans %= mod; if((a - b) % 2 != 0) ans --; printf("%llu\n",ans % mod); return 0; }