Dreamoon loves summing up something for no reason. One day he obtains two integers a and b occasionally. He wants to calculate the sum of all nice integers. Positive integer x is called nice if $\operatorname{mod}(x, b) \neq 0$ and $\frac{\operatorname{div}(x, b)}{\operatorname{mod}(x, b)} = k$, where k is some integer number in range [1, a].

By $\operatorname{div}(x, y)$ we denote the quotient of integer division of x and y. By $\operatorname{mod}(x, y)$ we denote the remainder of integer division of x and y. You can read more about these operations here: http://goo.gl/AcsXhT.

The answer may be large, so please print its remainder modulo 1 000 000 007 (10^9 + 7). Can you compute it faster than Dreamoon?


-----Input-----

The single line of the input contains two integers a, b (1 ≤ a, b ≤ 10^7).


-----Output-----

Print a single integer representing the answer modulo 1 000 000 007 (10^9 + 7).


-----Examples-----
Input
1 1

Output
0

Input
2 2

Output
8



-----Note-----

For the first sample, there are no nice integers because $\operatorname{mod}(x, 1)$ is always zero.

For the second sample, the set of nice integers is {3, 5}.

Difficulty: MEDIUM_HARD
Tags: Mathematics

Starter code:

Solutions:
def main():
	(a, b) = map(int, input().split(' '))
	if b == 1:
		print('0')
		return
	k = (a + 1) * a // 2
	z = k * b + a
	z *= b * (b - 1) // 2
	print(z % (10 ** 9 + 7))
	pass
main()


MOD = 10 ** 9 + 7

def sumTermsArith1(firstTerm, r, nbTerms):
	return nbTerms * (2 * firstTerm + (nbTerms - 1) * r) // 2

def solve(a, b):
	s = 0
	for rem in range(1, b):
		reason = rem * b
		s = (s + sumTermsArith1(reason + rem, reason, a)) % MOD
	return s

def solve2(a, b):
	reason = a * (b * (a + 1) + 2) // 2
	return sumTermsArith1(reason, reason, b - 1) % MOD
(a, b) = list(map(int, input().split()))
sol2 = solve2(a, b)
print(sol2)


(a, b) = map(int, input().split())
print((((b * a * (a + 1) >> 1) + a) * (b - 1) * b >> 1) % 1000000007)


mod = 1000000007
(a, b) = [int(x) for x in input().split()]
print((b - 1) * b * (b * (a + 1) + 2) * a * 250000002 % mod)


(a, b) = map(int, input().split())
sum = 0
mod = 1000000007

def c(i):
	mi = i * b + i
	ma = i * b * a + i
	return (mi + ma) * a // 2
sum = (c(1) + c(b - 1)) * (b - 1) // 2 % mod
print(sum)


(a, b) = map(int, input().split())
print(b * (b - 1) // 2 * (a * (a + 1) // 2 * b + a) % (10 ** 9 + 7))


import sys
import math
import collections
import heapq
input = sys.stdin.readline
(a, b) = (int(i) for i in input().split())
mod = 1000000007
print(b * (b - 1) * a * (b * a + b + 2) // 4 % mod)


(a, b) = map(int, input().split())
m = 1000000007
B = int(b * (b - 1) / 2 % m)
A1 = int(a * (a + 1) / 2 % m)
A = int((A1 * b + a) % m)
res = int(A * B % m)
print(res)


(a, b) = [int(i) for i in input().split()]
x = b * (b - 1) // 2
y = b * a * (a + 1) // 2 + a
print(x * y % (10 ** 9 + 7))


M = 1000000007
(a, b) = list(map(int, input().split(' ')))
res = b * (b - 1) // 2 * (a + b * a * (a + 1) // 2) % M
print(res)


(a, b) = map(int, input().split())
h = 1000000007
c = a * (b * b - b) // 2 % h
d = (a * a + a) // 2 % h
e = (b * b * b - b * b) // 2 % h
print((c + d * e % h) % h)


(a, b) = map(int, input().split())
print(b * (b - 1) * a * (a * b + b + 2) // 4 % 1000000007)


def solve():
	(a, b) = [int(x) for x in input().split()]
	print(int(b * (b - 1) // 2 * (a * (a + 1) * b // 2 + a) % (10 ** 9 + 7)))
solve()


(a, b) = list(map(int, input().split()))
modu = 10 ** 9 + 7
res = b * (b - 1) // 2 * (b * a * (a + 1) // 2 + a) % modu
print(res)


(a, b) = map(int, input().split())
nicesum = b * (b - 1) // 2 * (a * (a + 1) // 2) * b + b * (b - 1) // 2 * a
print(int(nicesum % 1000000007))


(a, b) = map(int, input().split())
MOD = 1000000007
x = a * (a + 1)
x = x // 2
x = x % MOD
x = x * b % MOD
x = (x + a) % MOD
x = x * b * (b - 1) // 2 % MOD
print(x)


def S(n):
	return n * (n + 1) // 2

def result(a, b):
	return S(b - 1) * b * S(a) + S(b - 1) * a
(a, b) = list(map(int, input().split()))
mod = 10 ** 9 + 7
print(result(a, b) % mod)


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)

def main():
	(a, b) = map(int, input().split())
	mod = int(1000000000.0 + 7)
	ans = 0
	suma = a * (a + 1) // 2
	suma %= mod
	ans = suma * b
	ans %= mod
	ans += a
	ans %= mod
	ans *= b * (b - 1) // 2
	ans %= mod
	print(ans)
	return
main()


import sys
import math
MAXNUM = math.inf
MINNUM = -1 * math.inf
ASCIILOWER = 97
ASCIIUPPER = 65
MODMAX = 1000000007

def getInt():
	return int(sys.stdin.readline().rstrip())

def getInts():
	return map(int, sys.stdin.readline().rstrip().split(' '))

def getString():
	return sys.stdin.readline().rstrip()

def printOutput(ans):
	sys.stdout.write()
	pass

def termadd(n):
	return n * (n + 1) // 2

def solve(a, b):
	return a * (b - 1) * b * (b * (a + 1) + 2) // 4 % MODMAX

def readinput():
	(a, b) = getInts()
	print(solve(a, b))
readinput()


from sys import stdin
from sys import stdout

def get():
	return stdin.readline().strip()

def getf():
	return [int(i) for i in get().split()]

def put(a, end='\n'):
	stdout.write(str(a) + end)

def putf(a):
	stdout.write(' '.join([str(i) for i in a]) + '\n')

def main():
	(a, b) = getf()
	ans = 0
	m = 1000000007
	ans = b * (b - 1) // 2 * (a + b * a * (a + 1) // 2) % m
	put(ans)
main()


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 1000000007

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(a, b) = value()
ans = 0
Nsum = (a * b * (a + 1) // 2 % M + a) % M
ans1 = b * (b - 1) // 2 % M
ans = ans1 * Nsum % M
print(ans)


(a, b) = map(int, input().split())
ans = a * (a + 1) * b * b * (b - 1)
ans //= 4
ans += a * b * (b - 1) // 2
MOD = 1000000007
ans %= MOD
print(ans)


mod = 10 ** 9 + 7
(a, b) = map(int, input().split())
t1 = b * (b - 1) // 2 % mod
t2 = a * (a + 1) // 2 % mod
t3 = t2 * b % mod + a
ans = t1 * t3 % mod
print(ans)


def solution(x, y):
	r = y * int((x + 1) * x / 2) + x
	r = r * int((y - 1) * y / 2)
	return r % 1000000007
(x, y) = map(int, input().split())
print(solution(x, y))


mod = 10 ** 9 + 7

def sum(x):
	return x * (x + 1) // 2

def solve():
	(a, b) = list(map(int, input().split()))
	print(sum(b - 1) * (b * sum(a) + a) % mod)
solve()


(a, b) = list(map(int, input().split(' ')))
res = a * (a * b + b + 2) * (b - 1) * b // 4
md = 10 ** 9 + 7
print(res % md)


from __future__ import print_function
from sys import stdin
from heapq import *
from math import log2, ceil, sqrt, gcd, log
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
rr = lambda x: reversed(range(x))
mod = int(1000000000.0) + 7
inf = float('inf')
(a, b) = gil()
if b == 1:
	print(0)
	exit()
ans = 0
for k in range(1, a + 1):
	ans += (k * b + 1) % mod
	if ans >= mod:
		ans %= mod
mul = (b - 1) * b // 2
mul %= mod
ans *= mul
ans %= mod
print(ans)


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


a = input()
a = a.split()
(a, b) = (int(a[0]), int(a[1]))
k2 = b * (b - 1) * a // 2
k = (b - 1) * b // 2 * b * (1 + a) * a // 2
res = (k + k2) % 1000000007
print(res)


(a, b) = map(int, input().split())
dangbra = b * (b - 1) // 2 * (a * (a + 1) // 2) * b + b * (b - 1) // 2 * a
print(int(dangbra % 1000000007))


load = [int(i) for i in input().split()]
a = load[0]
b = load[1]
print(b * (b - 1) // 2 * (b * a * (a + 1) // 2 + a) % 1000000007)


from sys import stdin
(a, b) = list(map(int, stdin.readline().split()))
mod = 10 ** 9 + 7
print((b * a * (a + 1) * b * (b - 1) // 4 + a * (b * (b - 1)) // 2) % mod)


from sys import stdin, stdout
from collections import defaultdict
import math
I = stdin.readline
P = stdout.write
mod = 10 ** 9 + 7
(a, b) = map(int, I().split())
p1 = a * b * b
p2 = (b - 1) * (a + 1)
p1 *= p2
p1 //= 4
p1 %= mod
p2 = a * b * (b - 1) // 2
p2 %= mod
p = p1 + p2
print(p % mod)


import math, sys
from collections import defaultdict, deque
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')

def I():
	return int(sys.stdin.readline())

def In():
	return map(int, sys.stdin.readline().split())

def Sn():
	return sys.stdin.readline().strip()

def Pr(x):
	sys.stdout.write(str(x) + '\n')

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gte(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def add(a, b):
	return (a + b) % P

def mul(a, b):
	return a * b % P

def su(n):
	return n * (n + 1) // 2 % P

def main():
	try:
		(a, b) = In()
		print(mul(add(mul(su(a), b), a), su(b - 1)))
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(1):
	main()


(a, b) = map(int, input().split())
r = 0
s = a * (a + 1) // 2 % 1000000007
r = (s * (b * (b - 1) // 2) * b + b * (b - 1) // 2 * a) % 1000000007
print(r % 1000000007)


(a, b) = [int(x) for x in input().split()]
MOD = 1000000007
sum1 = a * (b - 1) % MOD
sum1 = sum1 * b % MOD
sum1 = sum1 * 500000004 % MOD
sum2 = b * b % MOD
sum2 = sum2 * (b - 1) % MOD
sum2 = sum2 * a % MOD
sum2 = sum2 * (a + 1) % MOD
sum2 = sum2 * 250000002 % MOD
print(int((sum1 + sum2) % MOD))


(a, b) = map(int, input().split())
mod = 10 ** 9 + 7
ans = b * (b - 1) * (a * b * (a + 1) + 2 * a) // 4 % mod
print(ans)


l = list(map(int, input().split()))
a = l[0]
b = l[1]
c = a * (a + 1) // 2 * b + a
d = b * (b - 1) // 2
print(c * d % 1000000007)


reg = input().split(' ')
a = int(reg[0])
b = int(reg[1])
print(b * (b - 1) * a * (a * b + b + 2) // 4 % 1000000007)


a = input().split()
for i in range(len(a)):
	a[i] = int(a[i])
s = a[1] * (a[1] - 1) // 2
s1 = a[0] + a[0] * (a[0] + 1) // 2 * a[1]
s = s * s1
s = s % 1000000007
print(s)


import collections, itertools, functools, math
MOD = 1000000007

def solve():
	(a, b) = map(int, input().split())
	return (a * (a + 1) * b // 2 + a) * (b * (b - 1) // 2) % MOD
print(solve())


def main():
	MOD = int(1000000000.0) + 7
	(a, b) = map(int, input().split())
	k1 = (b - 1) * b // 2
	k2 = (a + 1) * a // 2
	k1 %= MOD
	k2 %= MOD
	ans = (k2 * b + a) % MOD
	ans = ans * k1 % MOD
	print(ans)
	return
main()


(a, b) = map(int, input().split())
MOD = 10 ** 9 + 7
x = a * (a + 1) * b // 2
x += a
x %= MOD
x *= b * (b - 1) // 2
x %= MOD
if b == 1:
	x = 0
print(x)


(a, b) = input().split(' ')
a = int(a)
b = int(b)
result = a * b * (b - 1) * (a * b + b + 2) // 4
result = result % (10 ** 9 + 7)
print(result)


def main():
	(a, b) = map(int, input().split())
	print(((a + 1) * b + 2) * a * b * (b - 1) // 4 % 1000000007 if b else 0)
main()


N = 10 ** 9 + 7
(a, b) = map(int, input().split())
ff1 = b + 1
flast = ff1 + b * (a - 1)
fsu = int((ff1 + flast) * a // 2)
lsu = fsu * (b - 1)
susu = int((fsu + lsu) * (b - 1) // 2)
print(susu % N)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass

def pmat(A):
	for ele in A:
		print(*ele, end='\n')
(a, b) = L()
ans = 0
ans += b * (b - 1) // 2 % mod * ((a + a * (a + 1) // 2 % mod * b) % mod)
ans %= mod
print(ans)
endtime = time.time()


x = [int(i) for i in input().split()]
a = x[0]
b = x[1]
x = b * (b - 1) // 2 % 1000000007
y = (a + b * a * (a + 1) // 2) % 1000000007
print(x * y % 1000000007)


def solve():
	(a, b) = [int(x) for x in input().split()]
	p = int(a * (a + 1) / 2)
	q = int(b * (b - 1) / 2)
	ans = q * (p * b + a)
	ans = ans % (10 ** 9 + 7)
	print(ans)
solve()


(a, b) = map(int, input().split())
ans = (a * (a + 1) // 2 * b + a) * (b * (b - 1)) // 2
print(ans % 1000000007)


def S(n):
	return n * (n + 1) // 2
string = input()
string_list = string.split()
(a, b) = (int(string_list[0]), int(string_list[1]))
itog = S(b - 1) * (S(a) * b + a)
itog = int(itog % 1000000007)
print(itog)