# -*- coding: utf-8 -*- """ Created on Sun Aug 1 14:11:40 2021 @author: sumitacchan """ A, B = map(int, input().split()) mod = 10**9 + 7 assert(0 <= A and A <= 10**18) assert(0 <= B and B <= 10**18) if A % 2 == B % 2: ans = ((2*A+1)*(2*B+1)+1)//2 else: ans = ((2*A+1)*(2*B+1)-1)//2 ans %= mod print(ans)