a, b = map(int, input().split()) if a > b: a, b = b, a ans = (2 * a + 1) * b + (a + 1 if (a + b) % 2 == 0 else a) print(ans % (10 ** 9 + 7))