mod = 10**9 + 7 A,B = map(int,input().split()) N0 = 2*(A//2) + 1 N1 = 2*(A - A//2) N0 %= mod N1 %= mod if B%2 == 1: ans = N1*(B+1) + N0*B else: ans = N0*(B+1) + N1*B print(ans%mod)