On a two-dimensional plane, there are m lines drawn parallel to the x axis, and n lines drawn parallel to the y axis.
Among the lines parallel to the x axis, the i-th from the bottom is represented by y = y_i.
Similarly, among the lines parallel to the y axis, the i-th from the left is represented by x = x_i.
For every rectangle that is formed by these lines, find its area, and print the total area modulo 10^9+7.
That is, for every quadruple (i,j,k,l) satisfying 1\leq i < j\leq n and 1\leq k < l\leq m, find the area of the rectangle formed by the lines x=x_i, x=x_j, y=y_k and y=y_l, and print the sum of these areas modulo 10^9+7.

-----Constraints-----
 - 2 \leq n,m \leq 10^5
 - -10^9 \leq x_1 < ... < x_n \leq 10^9
 - -10^9 \leq y_1 < ... < y_m \leq 10^9
 - x_i and y_i are integers.

-----Input-----
Input is given from Standard Input in the following format:
n m
x_1 x_2 ... x_n
y_1 y_2 ... y_m

-----Output-----
Print the total area of the rectangles, modulo 10^9+7.

-----Sample Input-----
3 3
1 3 4
1 3 6

-----Sample Output-----
60

The following figure illustrates this input:

The total area of the nine rectangles A, B, ..., I shown in the following figure, is 60.

Difficulty: MEDIUM

Solutions:
import sys
(n, m) = [int(x) for x in sys.stdin.readline().split()]
x = [int(x) for x in sys.stdin.readline().split()]
y = [int(x) for x in sys.stdin.readline().split()]
r = 0
mod = 10 ** 9 + 7

def sumof(a, b):
	s = 0
	for i in range(a):
		s += (2 * (i + 1) - a - 1) * b[i]
		s %= mod
	return s
r = sumof(n, x) * sumof(m, y) % mod
print(r)


MOD = 10 ** 9 + 7
(n, m) = [int(item) for item in input().split()]
x = [int(item) for item in input().split()]
y = [int(item) for item in input().split()]
(x_total, y_total) = (0, 0)
for i in range(1, n):
	x_total += i * (n - i) * (x[i] - x[i - 1]) % MOD
for i in range(1, m):
	y_total += i * (m - i) * (y[i] - y[i - 1]) % MOD
print(x_total * y_total % MOD)


import sys
readline = sys.stdin.readline
(N, M) = map(int, readline().split())
X = list(map(int, readline().split()))
Y = list(map(int, readline().split()))
DIV = 10 ** 9 + 7
xsum = 0
for i in range(1, len(X)):
	edge = X[i] - X[i - 1]
	times = i * (N - i)
	xsum += edge % DIV * (times % DIV) % DIV
	xsum %= DIV
ysum = 0
for i in range(1, len(Y)):
	edge = Y[i] - Y[i - 1]
	times = i * (M - i)
	ysum += edge % DIV * (times % DIV) % DIV
	ysum %= DIV
print(xsum * ysum % DIV)


import sys
tmp = sys.stdin.readline().strip().split(' ')
n = int(tmp[0])
m = int(tmp[1])
xs = sys.stdin.readline().strip().split(' ')
ys = sys.stdin.readline().strip().split(' ')
s_x = 0
s_y = 0
r = pow(10, 9) + 7
for i in range(1, n + 1):
	s_x = (s_x + (2 * i - 1 - n) * int(xs[i - 1])) % r
for i in range(1, m + 1):
	s_y = s_y + (2 * i - 1 - m) * int(ys[i - 1]) % r
print(s_x * s_y % r)


(n, m) = map(int, input().split())
x = map(int, input().split())
y = map(int, input().split())
tmp_x = 0
tmp_y = 0
mod = 10 ** 9 + 7
for (i, xi) in enumerate(x):
	tmp_x += (xi + 1) * (2 * i - (n - 1))
tmp_x = tmp_x % mod
for (i, yi) in enumerate(y):
	tmp_y += (yi + 1) * (2 * i - (m - 1))
tmp_y = tmp_y % mod
print(tmp_x * tmp_y % mod)


(N, M) = list(map(int, input().split()))
X = tuple(map(int, input().split()))
Y = tuple(map(int, input().split()))
MOD = 10 ** 9 + 7
X_sum = sum(((2 * i - N + 1) * x for (i, x) in enumerate(X))) % MOD
Y_sum = sum(((2 * i - M + 1) * y for (i, y) in enumerate(Y))) % MOD
print(X_sum * Y_sum % MOD)


(N, M) = map(int, input().split())
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
MOD = 10 ** 9 + 7

def f(Z):
	ans = 0
	for (k, z) in enumerate(Z):
		ans = (ans + k * z - (len(Z) - k - 1) * z) % MOD
	return ans
print(f(X) * f(Y) % MOD)


(n, m) = map(int, input().split())
x = [x for x in map(int, input().split())]
y = [y for y in map(int, input().split())]
sum_x = 0
sum_y = 0
ans = 0
for i in range(n):
	sum_x += (2 * i - n + 1) * x[i]
for j in range(m):
	sum_y += (2 * j - m + 1) * y[j]
ans = sum_x * sum_y
print(ans % 1000000007)


(N, M) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
numx = 0
for i in range(N):
	numx += -(N - i - 1) * X[i] + i * X[i]
numy = 0
for i in range(M):
	numy += -(M - i - 1) * Y[i] + i * Y[i]
print(numy * numx % MOD)


(N, M) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
mod = 10 ** 9 + 7
x = 0
y = 0
for i in range(N):
	x += (-N + 1 + 2 * i) * X[i]
	x %= mod
for i in range(M):
	y += (-M + 1 + 2 * i) * Y[i]
	y %= mod
print(x * y % mod)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
(sumx, sumy) = (0, 0)
mod = 10 ** 9 + 7
for i in range(n):
	sumx += i * x[i] - (n - i - 1) * x[i]
sumx %= mod
for i in range(m):
	sumy += i * y[i] - (m - i - 1) * y[i]
sumy %= mod
print(sumx * sumy % mod)


from itertools import accumulate
(n, m) = map(int, input().split())
(*x,) = map(int, input().split())
(*y,) = map(int, input().split())
acmx = list(accumulate(x))
acmy = list(accumulate(y))
mod = 10 ** 9 + 7
sumx = 0
for i in range(n - 1):
	sumx += acmx[n - 1] - acmx[i] - (n - i - 1) * x[i]
	sumx %= mod
sumy = 0
for i in range(m - 1):
	sumy += acmy[m - 1] - acmy[i] - (m - i - 1) * y[i]
	sumy %= mod
print(sumx * sumy % mod)


def main():
	MOD = 10 ** 9 + 7
	(N, M) = list(map(int, input().split(' ')))
	X = list(map(int, input().split(' ')))
	Y = list(map(int, input().split(' ')))
	X.sort()
	Y.sort()
	heights = [Y[i + 1] - Y[i] for i in range(M - 1)]
	widths = [X[j + 1] - X[j] for j in range(N - 1)]
	row_areas = [0 for _ in range(M - 1)]
	(first_row_area, norm_first_row_area) = (0, 0)
	for (j, w) in enumerate(widths):
		first_row_area += (1 + 0) * (M - 0 - 1) * (j + 1) * (N - j - 1) * w * heights[0]
		first_row_area %= MOD
		norm_first_row_area += (j + 1) * (N - j - 1) * w
		norm_first_row_area %= MOD
	row_areas[0] = first_row_area
	for i in range(1, M - 1):
		area = (i + 1) * (M - i - 1) * norm_first_row_area * heights[i]
		area %= MOD
		row_areas[i] = area
	ans = 0
	for a in row_areas:
		ans += a
		ans %= MOD
	print(ans)

def __starting_point():
	main()
__starting_point()


def read():
	return list(map(int, input().split()))
(n, m) = read()
x = read()
y = read()
(xs, ys) = (0, 0)
xs = sum([x[i] * (2 * i + 1 - n) for i in range(n)])
ys = sum([y[i] * (2 * i + 1 - m) for i in range(m)])
print(xs * ys % 1000000007)


MOD = 10 ** 9 + 7
(n, m) = map(int, input().split())
xlist = list(map(int, input().split()))
ylist = list(map(int, input().split()))
(x0, y0) = (xlist[0], ylist[0])
for i in range(n):
	xlist[i] -= x0
for i in range(m):
	ylist[i] -= y0
xsum = 0
for i in range(1, n):
	xsum += xlist[i] * i
	xsum -= xlist[i] * (n - i - 1)
	xsum %= MOD
ysum = 0
for i in range(1, m):
	ysum += ylist[i] * i
	ysum -= ylist[i] * (m - i - 1)
	ysum %= MOD
print(xsum * ysum % MOD)


MOD = 10 ** 9 + 7
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
w = 0
for i in range(n):
	if n - 1 - i - i <= 0:
		break
	w += (x[n - 1 - i] - x[i]) * (n - 1 - i - i)
	w %= MOD
h = 0
for i in range(m):
	if m - 1 - i - i <= 0:
		break
	h += (y[m - 1 - i] - y[i]) * (m - 1 - i - i)
	h %= MOD
ans = w * h % MOD
print(ans)


(N, M) = map(int, input().split())
X = sorted(list(map(int, input().split())))
Y = sorted(list(map(int, input().split())))
mod = 10 ** 9 + 7
(X_SUM, Y_SUM) = (0, 0)
for (i, x) in enumerate(X):
	X_SUM = (X_SUM + x * (i - (N - i - 1))) % mod
for (i, y) in enumerate(Y):
	Y_SUM = (Y_SUM + y * (i - (M - i - 1))) % mod
print(X_SUM * Y_SUM % mod)


(n, m) = map(int, input().split())
X = [int(x) for x in input().split()]
Y = [int(y) for y in input().split()]
p = 10 ** 9 + 7
print(sum([(X[i + 1] - X[i]) * (i + 1) * (n - i - 1) % p for i in range(n - 1)]) * sum([(Y[i + 1] - Y[i]) * (i + 1) * (m - i - 1) % p for i in range(m - 1)]) % p)


(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
ax = 0
for i in range(1, n):
	ax += (n - i) * i * (x[i] - x[i - 1]) % (10 ** 9 + 7)
ay = 0
for j in range(1, m):
	ay += (m - j) * j * (y[j] - y[j - 1]) % (10 ** 9 + 7)
print(ax * ay % (10 ** 9 + 7))


(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
sum_x = 0
for i in range(0, n):
	sum_x += i * x[i] - (n - (i + 1)) * x[i]
sum_y = 0
for i in range(0, m):
	sum_y += i * y[i] - (m - (i + 1)) * y[i]
ans = sum_x * sum_y
divide_num = pow(10, 9) + 7
print(ans % divide_num)


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
X = 0
Y = 0
mod = 10 ** 9 + 7
for i in range(n - 1):
	X += (a[i + 1] - a[i]) * (i + 1) * (n - i - 1)
	X %= mod
for i in range(m - 1):
	Y += (b[i + 1] - b[i]) * (i + 1) * (m - i - 1)
	Y %= mod
print(X * Y % mod)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7

def f(N, i):
	return i * (N - i + 1) % mod

def l(L, i):
	return (L[i] - L[i - 1]) % mod

def lf(L):
	N = len(L)
	return sum([l(L, i) * f(N - 1, i) % mod for i in range(1, N)])
print(lf(x) * lf(y) % mod)


MOD = 1000000007
(N, M) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
dx = [X[i + 1] - X[i] for i in range(N - 1)]
dy = [Y[i + 1] - Y[i] for i in range(M - 1)]
sx = 0
sy = 0
for i in range(N - 1):
	sx += dx[i] * (i + 1) * (N - 1 - i)
	sx %= MOD
for i in range(M - 1):
	sy += dy[i] * (i + 1) * (M - 1 - i)
	sy %= MOD
print(sx * sy % MOD)


mod = 10 ** 9 + 7
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
xx = [x[i + 1] - x[i] for i in range(n - 1)]
yy = [y[i + 1] - y[i] for i in range(m - 1)]
xsum = sum((xx[i] * (i + 1) * (n - 1 - i) for i in range(n - 1))) % mod
ysum = sum((yy[i] * (i + 1) * (m - 1 - i) for i in range(m - 1))) % mod
print(xsum * ysum % mod)


(N, M) = map(int, input().split())
MOD = 10 ** 9 + 7
x = list(map(int, input().split()))
y = list(map(int, input().split()))
cumsum_x = [0] * N
cumsum_y = [0] * M
cumsum_x[0] = x[0]
cumsum_y[0] = y[0]
for (i, xi) in enumerate(x[1:], 1):
	cumsum_x[i] = (cumsum_x[i - 1] + xi) % MOD
for (i, yi) in enumerate(y[1:], 1):
	cumsum_y[i] = (cumsum_y[i - 1] + yi) % MOD
X = Y = 0
for (i, xi) in enumerate(x):
	X += (cumsum_x[-1] - cumsum_x[i] - (N - i - 1) * xi) % MOD
	X %= MOD
for (i, yi) in enumerate(y):
	Y += (cumsum_y[-1] - cumsum_y[i] - (M - i - 1) * yi) % MOD
	Y %= MOD
print(X * Y % MOD)


(n, m) = map(int, input().split())
list_x = list(map(int, input().split()))
list_y = list(map(int, input().split()))
sum_x_pair = 0
for i in range(n):
	sum_x_pair += i * list_x[i] - (n - i - 1) * list_x[i]
sum_y_pair = 0
for j in range(m):
	sum_y_pair += j * list_y[j] - (m - j - 1) * list_y[j]
print(sum_x_pair * sum_y_pair % (7 + 10 ** 9))


(n, m) = map(int, input().split())
x = sorted(list(map(int, input().split())))
y = sorted(list(map(int, input().split())))
tx = 0
ty = 0
sx = 0
sy = 0
for i in range(n):
	tx += i * x[i] - sx
	sx += x[i]
for i in range(m):
	ty += i * y[i] - sy
	sy += y[i]
print(tx * ty % 1000000007)


mod = 10 ** 9 + 7
(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
sum_x = 0
for i in range(1, n + 1):
	sum_x += (i - 1) * x[i - 1] - (n - i) * x[i - 1]
sum_y = 0
for i in range(1, m + 1):
	sum_y += (i - 1) * y[i - 1] - (m - i) * y[i - 1]
print(sum_x * sum_y % mod)


import sys
input = sys.stdin.readline

def main():
	(n, m) = list(map(int, input().split()))
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	X = [x[i + 1] - x[i] for i in range(n - 1)]
	Y = [y[i + 1] - y[i] for i in range(m - 1)]
	mod = pow(10, 9) + 7
	for i in range(n - 1):
		X[i] = X[i] * (n - i - 1) * (i + 1) % mod
	sum_x = sum(X) % mod
	for i in range(m - 1):
		Y[i] = Y[i] * (m - i - 1) * (i + 1) % mod
	sum_y = sum(Y) % mod
	ans = sum_x * sum_y % mod
	print(ans)

def __starting_point():
	main()
__starting_point()


(n, m) = map(int, input().split())
X = [int(x) for x in input().split()]
Y = [int(x) for x in input().split()]

def f(a, n):
	return sum([(n - 1 - 2 * i) * x for (i, x) in enumerate(reversed(a))])
print(f(X, n) * f(Y, m) % (10 ** 9 + 7))


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
(x_sum, y_sum) = (0, 0)
for i in range(n):
	k = i + 1
	x_sum += (2 * k - n - 1) * x[i]
	x_sum = x_sum % 1000000007
for i in range(m):
	k = i + 1
	y_sum += (2 * k - m - 1) * y[i]
	y_sum = y_sum % 1000000007
ans = x_sum * y_sum % 1000000007
print(ans)


(n, m) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
mod = 1000000007
xtot = 0
ytot = 0
for i in range(n):
	xtot += (2 * i - n + 1) * x[i]
	xtot %= mod
for i in range(m):
	ytot += (2 * i - m + 1) * y[i]
	ytot %= mod
print(int(xtot * ytot % mod))


(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
x_diff = [x[i] - x[i - 1] for i in range(1, n)]
y_diff = [y[i] - y[i - 1] for i in range(1, m)]
x_sum = 0
for (i, dx) in enumerate(x_diff):
	x_sum = (x_sum + dx * (i + 1) * (n - i - 1) % mod) % mod
y_sum = 0
for (i, dy) in enumerate(y_diff):
	y_sum = (y_sum + dy * (i + 1) * (m - i - 1) % mod) % mod
print(x_sum * y_sum % mod)


(N, M) = map(int, input().split())
MOD = 10 ** 9 + 7
x = [int(c) for c in input().split()]
y = [int(c) for c in input().split()]
X = 0
Y = 0
for (i, c) in enumerate(x):
	X += i * c - (N - 1 - i) * c
	X %= MOD
for (i, c) in enumerate(y):
	Y += i * c - (M - 1 - i) * c
	Y %= MOD
print(X * Y % MOD)


(n, m) = map(int, input().split())
x_list = tuple(map(int, input().split()))
y_list = tuple(map(int, input().split()))
mod = 10 ** 9 + 7
x_sum = 0
for i in range(1, n + 1):
	x_sum += ((i - 1) * x_list[i - 1] - (n - i) * x_list[i - 1]) % mod
y_sum = 0
for i in range(1, m + 1):
	y_sum += ((i - 1) * y_list[i - 1] - (m - i) * y_list[i - 1]) % mod
print(x_sum * y_sum % mod)


(n, m) = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
total = 0
x_total = 0
y_total = 0
for i in range(len(x)):
	x_total += x[i] * i - x[i] * (n - (i + 1))
for i in range(len(y)):
	y_total += y[i] * i - y[i] * (m - (i + 1))
print(x_total * y_total % mod)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
y_sum = 0
ans = 0
x_sum = 0
for i in range(1, m):
	h = y[i] - y[i - 1]
	y_sum += h * i * (m - i)
	y_sum %= mod
for i in range(1, n):
	w = x[i] - x[i - 1]
	x_sum += w * i * (n - i)
	x_sum %= mod
print(x_sum * y_sum % mod)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
(a, b) = (0, 0)
for i in range(n):
	a += x[i] * i - x[i] * (n - i - 1)
for i in range(m):
	b += y[i] * i - y[i] * (m - i - 1)
print(a * b % mod)


(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
(vx, vy) = (0, 0)
for i in range(n - 1):
	vx += (x[i + 1] - x[i]) * (i + 1) * (n - i - 1)
	vx %= mod
for i in range(m - 1):
	vy += (y[i + 1] - y[i]) * (i + 1) * (m - i - 1)
	vy %= mod
print(vx * vy % mod)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
aj = 0
xsum = 0
(mod1, mod2) = (10 ** 9 + 7, 998244353)
mod = mod1
for j in range(1, n):
	aj = (aj + j * (x[j] - x[j - 1]) % mod) % mod
	xsum = (xsum + aj) % mod
bj = 0
ysum = 0
for j in range(1, m):
	bj = (bj + j * (y[j] - y[j - 1]) % mod) % mod
	ysum = (ysum + bj) % mod
print(xsum * ysum % mod)


import sys

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

def calc(x, n):
	ans = 0
	for (i, a) in enumerate(x):
		ans += (2 * i - n + 1) * a
	return ans
(n, m) = list(map(int, input().split()))
x = tuple(map(int, input().split()))
y = tuple(map(int, input().split()))
print(calc(x, n) * calc(y, m) % int(1000000000.0 + 7))


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
W = 0
for i in range(n - 1):
	W += (x[i + 1] - x[i]) * (i + 1) * (n - i - 1)
	W %= mod
H = 0
for i in range(m - 1):
	H += (y[i + 1] - y[i]) * (i + 1) * (m - i - 1)
	H %= mod
ans = H * W % mod
print(ans)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
w = 0
for i in range(n - 1):
	w += (x[i + 1] - x[i]) * (i + 1) * (n - i - 1)
	w %= mod
h = 0
for j in range(m - 1):
	h += (y[j + 1] - y[j]) * (j + 1) * (m - j - 1)
	h %= mod
print(h * w % mod)


(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
H = 0
W = 0
for i in range(n // 2):
	w = x[n - 1 - i] - x[i]
	if i == n // 2 - 1:
		if n % 2 == 1:
			w *= 2
	else:
		w *= n - 2 * i - 1
	W += w
	W %= mod
for j in range(m // 2):
	h = y[m - 1 - j] - y[j]
	if j == m // 2 - 1:
		if m % 2 == 1:
			h *= 2
	else:
		h *= m - 1 - 2 * j
	H += h
	H %= mod
S = H * W
print(S % mod)


def main():
	MOD = 10 ** 9 + 7
	(N, M) = list(map(int, input().split()))
	(*X,) = list(map(int, input().split()))
	(*Y,) = list(map(int, input().split()))

	def total(E):
		L = len(E)
		ret = 0
		for (i, (frm, to)) in enumerate(zip(E, E[1:]), start=1):
			ret = (ret + i * (L - i) * (to - frm)) % MOD
		return ret
	ans = total(X) * total(Y) % MOD
	print(ans)

def __starting_point():
	main()
__starting_point()


(n, m) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
mod = 10 ** 9 + 7
L = [i * (m - i) % mod for i in range(1, m)]
u = 0
for i in range(m - 1):
	u += (Y[i + 1] - Y[i]) * L[i] % mod
	u %= mod
M = [i * (n - i) % mod for i in range(1, n)]
ans = 0
for i in range(n - 1):
	ans += u * (X[i + 1] - X[i]) % mod * M[i] % mod
	ans %= mod
print(ans)


num = input().split(' ')
zahyou_x = input().split(' ')
zahyou_y = input().split(' ')
x_num = int(num[0])
y_num = int(num[1])
x_sum = 0
y_sum = 0
for i in range(x_num):
	x_sum += int(zahyou_x[i]) * (i * 2 - x_num + 1)
for i in range(y_num):
	y_sum += int(zahyou_y[i]) * (i * 2 - y_num + 1)
print(x_sum * y_sum % (10 ** 9 + 7))


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = pow(10, 9) + 7
ypoint = 0
for i in range(m - 1):
	ypoint += (y[i + 1] - y[i]) * (m - i - 1) * (i + 1)
	ypoint %= mod
ans = 0
for i in range(n - 1):
	ans += ypoint * (x[i + 1] - x[i]) * (n - i - 1) * (i + 1)
	ans %= mod
print(ans)


(n, m) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
DX = [X[i + 1] - X[i] for i in range(n - 1)]
DY = [Y[i + 1] - Y[i] for i in range(m - 1)]
mod = 10 ** 9 + 7
SUM_X = 0
SUM_Y = 0
for i in range(n - 1):
	SUM_X += (i + 1) * (n - 1 - i) * DX[i]
	SUM_X %= mod
for i in range(m - 1):
	SUM_Y += (i + 1) * (m - 1 - i) * DY[i]
	SUM_Y %= mod
ans = SUM_X * SUM_Y % mod
print(ans)


mod = 10 ** 9 + 7
(n, m) = map(int, input().split())
x = tuple(map(int, input().split()))
y = tuple(map(int, input().split()))
(lx, ly) = (0, 0)
for i in range(n):
	lx += i * x[i] - (n - i - 1) * x[i]
	lx %= mod
for i in range(m):
	ly += i * y[i] - (m - i - 1) * y[i]
	ly %= mod
print(lx * ly % mod)


(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
X = 0
Y = 0
for i in range(n - 1):
	t = x[i + 1] - x[i]
	X = (X + (i + 1) * (n - i - 1) * t) % MOD
for i in range(m - 1):
	t = y[i + 1] - y[i]
	Y = (Y + (i + 1) * (m - i - 1) * t) % MOD
print(X * Y % MOD)


(N, M) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
(X, Y) = (X[::-1], Y[::-1])
MOD = 10 ** 9 + 7
(x_sum, y_sum) = (0, 0)
for i in range(N):
	x_sum = x_sum + (N - i - 1) * X[i]
X = X[::-1]
for i in range(N):
	x_sum = x_sum - (N - i - 1) * X[i]
x_sum %= MOD
for i in range(M):
	y_sum = y_sum + (M - i - 1) * Y[i]
Y = Y[::-1]
for i in range(M):
	y_sum = y_sum - (M - i - 1) * Y[i]
y_sum %= MOD
print(x_sum * y_sum % MOD)


MOD = 10 ** 9 + 7
(n, m) = map(int, input().split())
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
(Sx, Sy) = (0, 0)
for i in range(n - 1):
	Sx += (X[i + 1] - X[i]) * (i + 1) * (n - 1 - i)
for k in range(m - 1):
	Sy += (Y[k + 1] - Y[k]) * (k + 1) * (m - 1 - k)
print(Sx * Sy % MOD)


line = input().split(' ')
n = int(line[0])
m = int(line[1])
x = 0
line1 = input().split(' ')
for (k, nn) in enumerate(line1):
	nn = int(nn)
	x += k * nn - (n - k - 1) * nn
y = 0
line2 = input().split(' ')
for (k, nn) in enumerate(line2):
	nn = int(nn)
	y += k * nn - (m - k - 1) * nn
print(x * y % (10 ** 9 + 7))


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
q = 10 ** 9 + 7
x_sum = 0
y_sum = 0
for i in range(n):
	x_sum += (2 * i - n + 1) * x[i]
for i in range(m):
	y_sum += (2 * i - m + 1) * y[i]
print(x_sum * y_sum % q)


mod = 10 ** 9 + 7
(n, m) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
p = 0
q = 0
for i in range(n - 1):
	p = (p + (X[i + 1] - X[i]) * (i + 1) % mod * (n - i - 1)) % mod
for i in range(m - 1):
	q = (q + (Y[i + 1] - Y[i]) * (i + 1) % mod * (m - i - 1)) % mod
print(p * q % mod)


Mod = 10 ** 9 + 7
n = [0, 0]
(n[0], n[1]) = map(int, input().split())
a = [0, 0]
for j in range(2):
	x = list(map(int, input().split()))
	s = 0
	for i in range(n[j]):
		s = (s + x[i] * (2 * i + 1 - n[j])) % Mod
	a[j] = s
print(a[0] * a[1] % Mod)


def calc(x):
	ans = 0
	n = len(x)
	for (i, a) in enumerate(x):
		ans += i * a - (n - 1 - i) * a
	return ans
(n, m) = map(int, input().split())
x = tuple(map(int, input().split()))
y = tuple(map(int, input().split()))
print(calc(x) * calc(y) % int(1000000000.0 + 7))


import sys
input = sys.stdin.buffer.readline
mod = 10 ** 9 + 7
(n, m) = map(int, input().split())
(*x,) = map(int, input().split())
(*y,) = map(int, input().split())
xd = [i - j for (j, i) in zip(x, x[1:])]
yd = [i - j for (j, i) in zip(y, y[1:])]
xs = ys = 0
for (i, d) in enumerate(xd):
	xs += d * (i + 1) * (n - 1 - i) % mod
	xs %= mod
for (i, d) in enumerate(yd):
	ys += d * (i + 1) * (m - 1 - i) % mod
	ys %= mod
print(xs * ys % mod)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
area_x = 0
for k in range(n):
	area_x += k * x[k] - (n - k - 1) * x[k]
area_y = 0
for l in range(m):
	area_y += l * y[l] - (m - l - 1) * y[l]
print(area_x * area_y % (10 ** 9 + 7))


import numpy as np
import sys
input = sys.stdin.readline
MOD = 10 ** 9 + 7
(n, m) = list(map(int, input().split()))
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
weight_n = np.array([(i + 1) * (n - i - 1) % MOD for i in range(n - 1)]).astype(np.int64)
weight_m = np.array([(i + 1) * (m - i - 1) % MOD for i in range(m - 1)]).astype(np.int64)
dxs = np.array([xs[i + 1] - xs[i] for i in range(n - 1)]).astype(np.int64)
dys = np.array([ys[i + 1] - ys[i] for i in range(m - 1)]).astype(np.int64)
t_x = np.sum(weight_n * dxs % MOD) % MOD
t_y = np.sum(weight_m * dys % MOD) % MOD
print(t_x * t_y % MOD)


(n, m) = map(int, input().split())
(*x,) = map(int, input().split())
(*y,) = map(int, input().split())
mod = 10 ** 9 + 7
print(sum(((2 * i - n - 1) * x[i - 1] for i in range(1, n + 1))) * sum(((2 * i - m - 1) * y[i - 1] for i in range(1, m + 1))) % mod)


import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy
(N, M) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = int(1000000000.0) + 7
xs = 0
for i in range(N):
	xs += i * X[i] % MOD - (N - i - 1) * X[i] % MOD + 2 * MOD
	xs %= MOD
ys = 0
for i in range(M):
	ys += i * Y[i] % MOD - (M - i - 1) * Y[i] % MOD + 2 * MOD
	ys %= MOD
print(xs * ys % MOD)


import sys
input = sys.stdin.readline

def read_values():
	return list(map(int, input().split()))

def read_list():
	return list(read_values())

def func(N, mod):
	F = [1]
	for i in range(1, N + 1):
		F.append(F[-1] * i % mod)
	return F
INV = {}

def inv(a, mod):
	if a in INV:
		return INV[a]
	r = pow(a, mod - 2, mod)
	INV[a] = r
	return r

def C(F, a, b, mod):
	return F[a] * inv(F[b], mod) * inv(F[a - b], mod) % mod

def main():
	mod = 10 ** 9 + 7
	(N, M) = read_values()
	X = read_list()
	Y = read_list()
	res_x = 0
	for i in range(N - 1):
		res_x += (i + 1) * (N - i - 1) * (X[i + 1] - X[i]) % mod
		res_x %= mod
	res_y = 0
	for i in range(M - 1):
		res_y += (i + 1) * (M - i - 1) * (Y[i + 1] - Y[i]) % mod
		res_y %= mod
	print(res_x * res_y % mod)

def __starting_point():
	main()
__starting_point()


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
yoko = 0
tate = 0
for i in range(0, len(x)):
	yoko += (n - 2 * i - 1) * x[i]
for i in range(0, len(y)):
	tate += (m - 2 * i - 1) * y[i]
print(yoko * tate % (10 ** 9 + 7))


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
xsm = 0
for (i, ex) in enumerate(x, 1):
	xsm -= ex * (n - i)
	xsm += ex * (i - 1)
	xsm %= mod
ysm = 0
for (i, ey) in enumerate(y, 1):
	ysm -= ey * (m - i)
	ysm += ey * (i - 1)
	ysm %= mod
ans = xsm * ysm % mod
print(ans)


mod = 1000000007
(n, m) = map(int, input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
xc = 0
for i in range(1, n):
	a = x[i] - x[i - 1]
	l = min(i, n - i)
	xc += a * (l * (n - l))
	xc %= mod
yc = 0
for i in range(1, m):
	a = y[i] - y[i - 1]
	l = min(i, m - i)
	yc += a * (l * (m - l))
	yc %= mod
print(xc * yc % mod)


import io
data = lambda : list(map(int, input().split()))
data()
q = lambda x: sum((j * (len(x) - 1 - 2 * i) for (i, j) in enumerate(x)))
print(q(data()) * q(data()) % (10 ** 9 + 7))


(N, M) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
w_sum = 0
for i in range(N // 2):
	times = N - 1 - i * 2
	w = X[-1 - i] - X[i]
	w_sum += w * times % MOD
	w_sum %= MOD
h_sum = 0
for i in range(M // 2):
	times = M - 1 - i * 2
	h = Y[-1 - i] - Y[i]
	h_sum += h * times % MOD
	h_sum %= MOD
print(w_sum * h_sum % MOD)


(m, n) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 1000000007
sum_x = 0
sum_y = 0
for k in range(m):
	sum_x += (2 * k + 1 - m) * X[k]
sum_x %= MOD
for l in range(n):
	sum_y += (2 * l + 1 - n) * Y[l]
sum_y %= MOD
Answer = sum_x * sum_y % MOD
print(Answer)


(n, m) = [int(i) for i in input().split(' ')]
x_list = [int(i) for i in input().split(' ')]
y_list = [int(i) for i in input().split(' ')]
x_res = 0
for i in range(n):
	x_res += (i - (n - i - 1)) * x_list[i]
y_res = 0
for j in range(m):
	y_res += (j - (m - j - 1)) * y_list[j]
print(x_res * y_res % (10 ** 9 + 7))


mod = 10 ** 9 + 7

def solve(N, X):
	return sum(((2 * k - N + 1) * x for (k, x) in enumerate(X))) % mod
(N, M, *XY) = map(int, open(0).read().split())
(X, Y) = (XY[:N], XY[N:])
print(solve(N, X) * solve(M, Y) % mod)


(N, M) = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
MOD = 10 ** 9 + 7
total_w = total_h = 0
for n in range(1, N):
	w = xs[n] - xs[n - 1]
	w = w * n * (N - n) % MOD
	total_w = (total_w + w) % MOD
for n in range(1, M):
	h = ys[n] - ys[n - 1]
	h = h * n * (M - n) % MOD
	total_h = (total_h + h) % MOD
ans = total_w * total_h % MOD
print(ans)


(n, m) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
mod = 10 ** 9 + 7
SX = 0
for i in range(n):
	SX += i * X[i] - (n - 1 - i) * X[i]
SX %= mod
SY = 0
for i in range(m):
	SY += i * Y[i] - (m - 1 - i) * Y[i]
SY %= mod
ans = SX * SY
print(ans % mod)


def rren():
	return list(map(int, input().split()))
(n, m) = rren()
x = rren()
y = rren()
ans = 0
x_sum = 0
y_sum = 0
for now_x in range(n):
	x_sum += x[now_x] * (now_x - (n - 1 - now_x))
for now_y in range(m):
	y_sum += y[now_y] * (now_y - (m - 1 - now_y))
print(x_sum * y_sum % 1000000007)


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

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

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

class mint:

	def __init__(self, x):
		self.__x = x % md

	def __str__(self):
		return str(self.__x)

	def __add__(self, other):
		if isinstance(other, mint):
			other = other.__x
		return mint(self.__x + other)

	def __sub__(self, other):
		if isinstance(other, mint):
			other = other.__x
		return mint(self.__x - other)

	def __rsub__(self, other):
		return mint(other - self.__x)

	def __mul__(self, other):
		if isinstance(other, mint):
			other = other.__x
		return mint(self.__x * other)
	__radd__ = __add__
	__rmul__ = __mul__

	def __truediv__(self, other):
		if isinstance(other, mint):
			other = other.__x
		return mint(self.__x * pow(other, md - 2, md))

	def __pow__(self, power, modulo=None):
		return mint(pow(self.__x, power, md))
md = 10 ** 9 + 7

def main():
	(n, m) = MI()
	xx = LI()
	yy = LI()
	ans = mint(0)
	byj = mint(0)
	for j in range(m - 1):
		byj += (j + 1) * (m - j - 1) * (yy[j + 1] - yy[j])
	for i in range(n - 1):
		ans += (xx[i + 1] - xx[i]) * (i + 1) * (n - i - 1) * byj
	print(ans)
main()


(n, m) = map(int, input().split())
lists = list(map(int, input().split()))
sub = list(map(int, input().split()))
mod = 10 ** 9 + 7
tate = 0
yoko = 0
for i in range(n):
	tate += lists[i] * (2 * (i + 1) - 1 - n)
for j in range(m):
	yoko += sub[j] * (2 * (j + 1) - 1 - m)
print(tate % mod * (yoko % mod) % mod)


import sys
MOD = 1000000007

def solve(n: int, m: int, x: 'List[int]', y: 'List[int]'):
	X = 0
	for k in range(1, n + 1):
		X += (k - 1) * x[k - 1] - (n - k) * x[k - 1]
		X %= MOD
	Y = 0
	for k in range(1, m + 1):
		Y += (k - 1) * y[k - 1] - (m - k) * y[k - 1]
		Y %= MOD
	print(X * Y % MOD)
	return

def main():

	def iterate_tokens():
		for line in sys.stdin:
			for word in line.split():
				yield word
	tokens = iterate_tokens()
	n = int(next(tokens))
	m = int(next(tokens))
	x = [int(next(tokens)) for _ in range(n)]
	y = [int(next(tokens)) for _ in range(m)]
	solve(n, m, x, y)

def __starting_point():
	main()
__starting_point()


(n, m) = map(int, input().split())
x = map(int, input().split())
y = map(int, input().split())
tmp_x = 0
for (i, xi) in enumerate(x):
	tmp_x += (xi + 1) * (2 * i - (n - 1))
tmp_x = tmp_x % 1000000007
tmp_y = 0
for (i, yi) in enumerate(y):
	tmp_y += (yi + 1) * (2 * i - (m - 1))
tmp_y = tmp_y % 1000000007
print(tmp_x * tmp_y % 1000000007)


from itertools import accumulate
(n, m) = map(int, input().split())
(*x,) = map(int, input().split())
(*y,) = map(int, input().split())
mod = 10 ** 9 + 7
xsum = list(accumulate(x))
ysum = list(accumulate(y))
xt = 0
yt = 0
for i in range(1, n):
	xt += i * x[i] - xsum[i - 1]
	xt %= mod
for i in range(1, m):
	yt += i * y[i] - ysum[i - 1]
	yt %= mod
print(xt * yt % mod)


(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
a = 0
b = 0
Mod = 10 ** 9 + 7
for k in range(1, n + 1):
	a += (k - 1) * x[k - 1] - (n - k) * x[k - 1]
for j in range(1, m + 1):
	b += (j - 1) * y[j - 1] - (m - j) * y[j - 1]
res = a * b
print(a * b % Mod)


import sys
input = sys.stdin.readline
mod = 10 ** 9 + 7
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
f = 0
for j in range(m - 1):
	f = (f + (y[j + 1] - y[j]) * (j + 1) * (m - j - 1)) % mod
ans = 0
for i in range(n - 1):
	ans = (ans + (x[i + 1] - x[i]) * (i + 1) * (n - i - 1) * f) % mod
print(ans)


(n, m) = map(int, input().split())
X = sorted([int(x) for x in input().split()])
Y = sorted([int(x) for x in input().split()])
mod = 1000000007

def diffSum(X):
	l = len(X)
	Res = [(2 * i - l + 1) * X[i] for i in range(l)]
	return sum(Res) % mod
print(diffSum(X) * diffSum(Y) % mod)


(n, m) = map(int, input().split())
x = [0] + list(map(int, input().split()))
y = [0] + list(map(int, input().split()))
mod = 10 ** 9 + 7
(a1, a2) = (0, 0)
for k in range(1, n + 1):
	a1 += (k * 2 - n - 1) * x[k]
for k in range(1, m + 1):
	a2 += (k * 2 - m - 1) * y[k]
print(a1 * a2 % mod)


(n, m) = map(int, input().split())
MOD = 1000000007
x = list(map(int, input().split()))
y = list(map(int, input().split()))
sx = 0
sy = 0
for i in range(1, n):
	sx += (x[i] - x[i - 1]) * i * (n - i)
	sx %= MOD
for i in range(1, m):
	sy += (y[i] - y[i - 1]) * i * (m - i)
	sy %= MOD
print(sx * sy % MOD)


mod = 1000000007
(N, M) = map(int, input().split())
s = 0
k = 0
L = list(map(int, input().split()))
R = list(map(int, input().split()))
for i in range(N):
	s += L[i] * (2 * i - N + 1)
for j in range(M):
	k += R[j] * (2 * j - M + 1)
print(k % mod * s % mod % mod)


(n, m) = map(int, input().strip().split(' '))
x = list(map(int, input().strip().split(' ')))
y = list(map(int, input().strip().split(' ')))
X = sum([(2 * i - n + 1) * x[i] for i in range(n)]) % 1000000007
Y = sum([(2 * i - m + 1) * y[i] for i in range(m)]) % 1000000007
ans = X * Y % 1000000007
print(ans)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
w = 0
ans = 0
for i in range(n - 1):
	w += (x[i + 1] - x[i]) * (i + 1) * (n - i - 1)
	w %= 10 ** 9 + 7
for i in range(m - 1):
	ans += w * (y[i + 1] - y[i]) * (i + 1) * (m - i - 1)
	ans %= 10 ** 9 + 7
print(ans)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
ctx = 0
cty = 0
for i in range(n):
	ctx += (2 * i - n + 1) * x[i]
	ctx %= mod
for i in range(m):
	cty += (2 * i - m + 1) * y[i]
	cty %= mod
print(ctx * cty % mod)


(n, m) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
mod = 10 ** 9 + 7
x_tmp = 0
for i in range(n):
	x_tmp += (2 * i - n + 1) * X[i]
y_tmp = 0
for i in range(m):
	y_tmp += (2 * i - m + 1) * Y[i]
print(x_tmp * y_tmp % mod)


def main():
	(n, m) = map(int, input().split())
	s = list(map(int, input().split()))
	t = list(map(int, input().split()))
	mod = 10 ** 9 + 7
	s = [(s[i + 1] - s[i]) * (i + 1) * (n - i - 1) % mod for i in range(n - 1)]
	t = [(t[i + 1] - t[i]) * (i + 1) * (m - i - 1) % mod for i in range(m - 1)]
	print(sum(s) * sum(t) % mod)
main()


(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
sx = 0
for i in range(n - 1):
	xi = (x[i + 1] - x[i]) % mod
	sx += (i + 1) * (n - i - 1) * xi % mod
	sx %= mod
sy = 0
for i in range(m - 1):
	yi = (y[i + 1] - y[i]) % mod
	sy += (i + 1) * (m - i - 1) * yi % mod
	sy %= mod
print(sx * sy % mod)


MOD = 1000000007
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
xs = ys = 0
for i in range(1, n + 1):
	xs += (i - 1) * x[i - 1] - (n - i) * x[i - 1]
	xs %= MOD
for i in range(1, m + 1):
	ys += (i - 1) * y[i - 1] - (m - i) * y[i - 1]
	ys %= MOD
ans = xs * ys
print(ans % MOD)


def cmb(n, r, mod):
	if r < 0 or r > n:
		return 0
	r = min(r, n - r)
	return g1[n] * g2[r] * g2[n - r] % mod
mod = 10 ** 9 + 7
N = 10 ** 4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range(2, N + 1):
	g1.append(g1[-1] * i % mod)
	inverse.append(-inverse[mod % i] * (mod // i) % mod)
	g2.append(g2[-1] * inverse[-1] % mod)
(n, m) = list(map(int, input().split()))
X = [0] + sorted(list(map(int, input().split())))
Y = [0] + sorted(list(map(int, input().split())))
sum1 = 0
sum2 = 0
MOD = 10 ** 9 + 7
for i in range(1, n + 1):
	sum1 += ((i - 1) * X[i] - (n - i) * X[i]) % MOD
for i in range(1, m + 1):
	sum2 += ((i - 1) * Y[i] - (m - i) * Y[i]) % MOD
print(sum1 * sum2 % MOD)


import sys
input = sys.stdin.readline
INF = 10 ** 9 + 7
(n, m) = map(int, input().split())
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))
X = 0
plus = 0
for i in range(n - 1):
	plus = (plus + (x_list[i + 1] - x_list[i]) * (i + 1)) % INF
	X = (X + plus) % INF
Y = 0
plus = 0
for i in range(m - 1):
	plus = (plus + (y_list[i + 1] - y_list[i]) * (i + 1)) % INF
	Y = (Y + plus) % INF
ans = X * Y % INF
print(ans)


(n, m) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
mod = 10 ** 9 + 7
X.sort()
Y.sort()
x = 0
y = 0
for i in range(1, n):
	x = (x + (X[i] - X[i - 1]) * i * (n - i)) % mod
for i in range(1, m):
	y = (y + (Y[i] - Y[i - 1]) * i * (m - i)) % mod
print(x * y % mod)


MOD = 1000000007
(n, m) = map(int, input().split())
xlst = list(map(int, input().split()))
ylst = list(map(int, input().split()))
xs = 0
for i in range(n - 1):
	w = xlst[i + 1] - xlst[i]
	xs += w * (i + 1) * (n - i - 1)
	xs %= MOD
ys = 0
for i in range(m - 1):
	h = ylst[i + 1] - ylst[i]
	ys += h * (i + 1) * (m - i - 1)
	ys %= MOD
print(xs * ys % MOD)


(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7

def count(li):
	l = 1 - len(li)
	cnt = 0
	for (ind, i) in enumerate(li):
		cnt += i * (l + 2 * ind)
	return cnt % mod
print(count(x) * count(y) % mod)


MOD = 10 ** 9 + 7
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x_dif = [b - a for (a, b) in zip(x, x[1:])]
y_dif = [b - a for (a, b) in zip(y, y[1:])]

def cumd(dif, line):
	d_sum = 0
	for (i, d) in enumerate(dif, 1):
		d_sum += d * i * (line - i) % MOD
		d_sum %= MOD
	return d_sum
dx_sum = cumd(x_dif, n)
dy_sum = cumd(y_dif, m)
print(dx_sum * dy_sum % MOD)


(n, m) = map(int, input().split(' '))
x = list(map(int, input().split(' ')))
y = list(map(int, input().split(' ')))
MOD = 1000000007
xsum = 0
ysum = 0
for i in range(n - 1):
	diff = x[i + 1] - x[i]
	xsum += diff * (i + 1) % MOD * (n - 1 - i) % MOD
for i in range(m - 1):
	diff = y[i + 1] - y[i]
	ysum += diff * (i + 1) % MOD * (m - 1 - i) % MOD
print(xsum * ysum % MOD)


(n, m) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
(sx, sy) = (0, 0)
for i in range(n):
	t = 2 * i + 1 - n
	t *= X[i]
	t %= MOD
	sx += t
	sx %= MOD
for j in range(m):
	t = 2 * j + 1 - m
	t *= Y[j]
	t %= MOD
	sy += t
	sy %= MOD
print(sx * sy % MOD)


(s, t) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

def calc(li):
	div = 10 ** 9 + 7
	li_size = len(li)
	su_m = 0
	for k in range(li_size):
		su_m += (2 * k + 1 - li_size) * li[k] % div
	return su_m
x_sum = calc(x)
y_sum = calc(y)
print(x_sum * y_sum % (10 ** 9 + 7))


b = input().split()
c = [int(b[i]) for i in range(len(b))]
d = input().split()
e = [int(d[i]) for i in range(c[0])]
r = input().split()
f = [int(r[i]) for i in range(c[1])]
ansx = 0
for i in range(c[0]):
	tmp = i * e[i] - (c[0] - i - 1) * e[i]
	ansx += tmp
ansy = 0
for j in range(c[1]):
	tmp = j * f[j] - (c[1] - j - 1) * f[j]
	ansy += tmp
print(ansx * ansy % (10 ** 9 + 7))


in1 = list(input().split())
nx = int(in1[0])
ny = int(in1[1])
x = list(input().split())
y = list(input().split())
sx = sum([int(x[i]) * (2 * i - nx + 1) for i in range(nx)])
sy = sum([int(y[i]) * (2 * i - ny + 1) for i in range(ny)])
print(sx * sy % (10 ** 9 + 7))


mo = 10 ** 9 + 7
(n, m) = map(int, input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
(X, Y) = (0, 0)
for i in range(n):
	X += x[i] * (n - 2 * i - 1)
	X %= mo
for i in range(m):
	Y += y[i] * (m - 2 * i - 1)
	Y %= mo
print(X * Y % mo)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
xx = [x[i + 1] - x[i] for i in range(n - 1)]
yy = [y[i + 1] - y[i] for i in range(m - 1)]
print(sum((xx[i] * (i + 1) * (n - 1 - i) for i in range(n - 1))) * sum((yy[i] * (i + 1) * (m - 1 - i) for i in range(m - 1))) % MOD)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
(xs, ys) = (0, 0)
mod = 10 ** 9 + 7
for i in range(1, n):
	xs += (x[i] - x[i - 1]) * i * (n - i) % mod
for i in range(1, m):
	ys += (y[i] - y[i - 1]) * i * (m - i) % mod
print(xs * ys % mod)


mod_number = 1000000007
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
ans_x = 0
ans_y = 0
for i in range(n - 1):
	ans_x += (x[i + 1] - x[i]) * (i + 1) * (n - i - 1) % mod_number
for i in range(m - 1):
	ans_y += (y[i + 1] - y[i]) * (i + 1) * (m - i - 1) % mod_number
print(ans_x * ans_y % mod_number)


import sys
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7

def resolve():
	(n, m) = list(map(int, input().split()))
	X = list(map(int, input().split()))
	Y = list(map(int, input().split()))
	XL = [X[i] - X[i - 1] for i in range(1, n)]
	YL = [Y[i] - Y[i - 1] for i in range(1, m)]
	cnt_X = [i * (n - i) % mod for i in range(1, n)]
	cnt_Y = [i * (m - i) % mod for i in range(1, m)]
	total_X = sum([XL[i] * cnt_X[i] % mod for i in range(n - 1)]) % mod
	total_Y = sum([YL[i] * cnt_Y[i] % mod for i in range(m - 1)]) % mod
	res = total_X * total_Y % mod
	print(res)

def __starting_point():
	resolve()
__starting_point()


(N, M) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
a = 0
b = 0
mod = 10 ** 9 + 7
for n in range(N):
	a += (2 * n - N + 1) * X[n]
	a %= mod
for m in range(M):
	b += (2 * m - M + 1) * Y[m]
	b %= mod
print(a * b % mod)


(n, m) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
X_sum = 0
for i in range(n):
	X_sum += (2 * i - n + 1) * X[i]
	X_sum = X_sum % MOD
Y_sum = 0
for j in range(m):
	Y_sum += (2 * j - m + 1) * Y[j]
	Y_sum = Y_sum % MOD
print(X_sum * Y_sum % MOD)


(n, m) = (int(i) for i in input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
(difx, dify, num, num2, mod) = ([], [], 0, 0, 10 ** 9 + 7)
for i in range(1, n):
	difx.append(x[i] - x[i - 1])
for i in range(1, m):
	dify.append(y[i] - y[i - 1])
for i in range(n - 1):
	num = (num + (i + 1) * (n - i - 1) * difx[i]) % mod
for i in range(m - 1):
	num2 = (num2 + (i + 1) * (m - i - 1) * dify[i]) % mod
print(num * num2 % mod)


s = input()
s = s.split()
(n, m) = (int(s[0]), int(s[1]))
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
mod = 10 ** 9 + 7
xrange = 0
for i in range(n):
	xrange -= x[i] * (n - i * 2 - 1)
yrange = 0
for i in range(m):
	yrange -= (m - i * 2 - 1) * y[i]
ans = xrange * yrange % mod
print(ans)


(n, m) = map(int, input().split())
p = 10 ** 9 + 7
X = [int(x) for x in input().split()]
Y = [int(x) for x in input().split()]
XX = [(X[i + 1] - X[i]) * (n - i - 1) * (i + 1) % p for i in range(n - 1)]
YY = [(Y[j + 1] - Y[j]) * (m - j - 1) * (j + 1) % p for j in range(m - 1)]
print(sum(XX) * sum(YY) % p)


def read():
	return list(map(int, input().split()))
MOD = 10 ** 9 + 7
(n, m) = read()
x = read()
y = read()
(xs, ys) = (0, 0)
for i in range(n):
	xs += x[i] * (2 * i + 1 - n)
	xs %= MOD
for i in range(m):
	ys += y[i] * (2 * i + 1 - m)
	ys %= MOD
print(xs * ys % MOD)


MOD = 10 ** 9 + 7
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x_sum = 0
for (k, value) in enumerate(x):
	x_sum += (2 * (k + 1) - n - 1) * value
	x_sum %= MOD
y_sum = 0
for (k, value) in enumerate(y):
	y_sum += (2 * (k + 1) - m - 1) * value
	y_sum %= MOD
print(x_sum * y_sum % MOD)


(n, m) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
mod = 10 ** 9 + 7
ans1 = 0
for k in range(1, n + 1):
	ans1 += (2 * k - 1 - n) * X[k - 1]
	ans1 %= mod
ans2 = 0
for k in range(1, m + 1):
	ans2 += (2 * k - 1 - m) * Y[k - 1]
	ans2 %= mod
print(ans1 * ans2 % mod)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
ans = 0
temp1 = 0
temp2 = 0
for i in range(n):
	temp1 += i * x[i] - (n - (i + 1)) * x[i]
	temp1 %= MOD
for i in range(m):
	temp2 += i * y[i] - (m - (i + 1)) * y[i]
	temp2 %= MOD
ans = temp1 * temp2
ans %= MOD
print(ans)


mod = 10 ** 9 + 7
(n, m) = map(int, input().split())
X = tuple(map(int, input().split()))
Y = tuple(map(int, input().split()))
(ans_x, ans_y) = (0, 0)
for (i, x) in enumerate(X):
	ans_x += (2 * i + 1 - n) * x
	ans_x %= mod
for (i, y) in enumerate(Y):
	ans_y += (2 * i + 1 - m) * y
	ans_y %= mod
print(ans_x * ans_y % mod)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
M = 10 ** 9 + 7

def get_diffsum(X, M):
	left_sum = sum(X)
	left_count = len(X)
	ans = 0
	for x in X:
		left_sum -= x
		left_count -= 1
		ans += left_sum - left_count * x
		ans %= M
	return ans
print(get_diffsum(X, M) * get_diffsum(Y, M) % M)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.sort()
y.sort()
N = 10 ** 9 + 7
Lx = 0
Ly = 0
for i in range(n):
	Lx += (-n + 2 * i + 1) * x[i]
	Lx %= N
for i in range(m):
	Ly += (-m + 2 * i + 1) * y[i]
	Ly %= N
ans = Lx * Ly % N
print(ans)


(n, m) = [int(j) for j in input().split()]
x = [int(j) for j in input().split()]
y = [int(j) for j in input().split()]
mod = 10 ** 9 + 7
sx = 0
sy = 0
for i in range(n):
	sx += (2 * i - n + 1) * x[i]
	sx = sx % mod
for i in range(m):
	sy += (2 * i - m + 1) * y[i]
	sy = sy % mod
print(sx * sy % mod)


import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache

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

def INT():
	return int(input())

def MAP():
	return list(map(int, input().split()))

def LIST():
	return list(map(int, input().split()))

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

def ZIP(n):
	return list(zip(*(MAP() for _ in range(n))))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
(n, m) = MAP()
x = LIST()
y = LIST()

def acc(A):
	acc = []
	tmp = 0
	for a in A:
		tmp += a
		tmp %= mod
		acc.append(tmp)
	return acc

def sum_combinations(A, k):
	A_acc = acc(A)
	A_sum = 0
	for i in range(k):
		tmp = (A_acc[-1] - A_acc[i]) % mod
		tmp = (tmp - A[i] * (k - 1 - i) % mod) % mod
		A_sum = (A_sum + tmp) % mod
	return A_sum
print(sum_combinations(x, n) * sum_combinations(y, m) % mod)


(N, M) = list(map(int, input().split()))
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
cnt = 0
for i in range(M - 1):
	l = Y[i + 1] - Y[i]
	var = (i + 1) * (M - (i + 1))
	cnt += l * var
	cnt %= MOD
ans = 0
for i in range(N - 1):
	l = X[i + 1] - X[i]
	var = (i + 1) * (N - (i + 1))
	ans += l * var * cnt
	ans %= MOD
print(ans)


(n, m) = map(int, input().split())
(*x,) = map(int, input().split())
(*y,) = map(int, input().split())
MOD = 10 ** 9 + 7

def calc(v, l):
	r = 0
	for i in range(l):
		r = r + i * v[i] - (l - 1 - i) * v[i]
		r %= MOD
	return r
print(calc(x, n) * calc(y, m) % MOD)


(n, m) = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
MOD = int(1000000000.0 + 7)
row = sum([(i + 1) * (n - i - 1) * (xs[i + 1] - xs[i]) % MOD for i in range(n - 1)]) % MOD
col = sum([(i + 1) * (m - i - 1) * (ys[i + 1] - ys[i]) % MOD for i in range(m - 1)]) % MOD
ans = row * col % MOD
print(ans)


(N, M) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
sum_x = 0
sum_y = 0
for i in range(N):
	sum_x += (i - (N - i - 1)) * X[i] % MOD
for j in range(M):
	sum_y += (j - (M - j - 1)) * Y[j] % MOD
print(sum_x * sum_y % MOD)


MOD = 10 ** 9 + 7
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x_sum = sum(((2 * i - n + 1) * x[i] for i in range(n)))
y_sum = sum(((2 * i - m + 1) * y[i] for i in range(m)))
print(x_sum * y_sum % MOD)


I = lambda : list(map(int, input().split()))
I()
F = lambda x: sum((j * (len(x) - 1 - 2 * i) for (i, j) in enumerate(x)))
print(F(I()) * F(I()) % (10 ** 9 + 7))


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
(ans, ans2) = (0, 0)
for i in range(n):
	ans = (ans + (-n + 2 * i + 1) * x[i]) % mod
for i in range(m):
	ans2 = (ans2 + (-m + 2 * i + 1) * y[i]) % mod
print(ans * ans2 % mod)


(N, M) = map(int, input().split())
(X, Y) = (list(map(int, input().split())) for i in range(2))
(x1, x2) = ([0] * N for i in range(2))
(y1, y2) = ([0] * M for i in range(2))
m = 10 ** 9 + 7
for i in range(N - 1):
	x1[i + 1] = (x1[i] + (X[i + 1] - X[i]) * (i + 1)) % m
	x2[i + 1] = (x2[i] + x1[i]) % m
for i in range(M - 1):
	y1[i + 1] = (y1[i] + (Y[i + 1] - Y[i]) * (i + 1)) % m
	y2[i + 1] = (y2[i] + y1[i]) % m
print((x1[-1] + x2[-1]) * (y1[-1] + y2[-1]) % m)


import sys
import numpy as np
sr = lambda : sys.stdin.readline().rstrip()
ir = lambda : int(sr())
lr = lambda : list(map(int, sr().split()))
MOD = 10 ** 9 + 7
(n, m) = lr()
X = np.array(lr())
Y = np.array(lr())
coef_x = np.arange(n) * 2 - (n - 1)
xsum = (X * coef_x % MOD).sum() % MOD
coef_y = np.arange(m) * 2 - (m - 1)
ysum = (Y * coef_y % MOD).sum() % MOD
answer = xsum * ysum % MOD
print(answer)


def d_rectangles(MOD=10 ** 9 + 7):
	(N, M) = [int(i) for i in input().split()]
	X = [int(i) for i in input().split()]
	Y = [int(i) for i in input().split()]
	ans1 = sum([x * (2 * k - N - 1) for (k, x) in enumerate(X, 1)])
	ans2 = sum([y * (2 * k - M - 1) for (k, y) in enumerate(Y, 1)])
	return ans1 * ans2 % MOD
print(d_rectangles())


import sys

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return list(map(int, input().split()))

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7
(N, M) = MAP()
A = LIST()
B = LIST()
lsm = rsm = 0
for i in range(N):
	lsm += A[i] * (N - i - 1)
	rsm += A[i] * i
	lsm %= MOD
	rsm %= MOD
h = rsm - lsm
lsm = rsm = 0
for i in range(M):
	lsm += B[i] * (M - i - 1)
	rsm += B[i] * i
	lsm %= MOD
	rsm %= MOD
w = rsm - lsm
ans = h * w % MOD
print(ans)


(n, m) = map(int, input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
MOD = 10 ** 9 + 7
sx = 0
pre = 0
for i in range(1, n):
	pre += (x[i] - x[i - 1]) * i
	sx += pre
	sx %= MOD
sy = 0
pre = 0
for i in range(1, m):
	pre += (y[i] - y[i - 1]) * i
	sy += pre
	sy %= MOD
print(sx * sy % MOD)


(N, M) = map(int, input().split())
X = sorted(list(map(int, input().split())), reverse=True)
Y = sorted(list(map(int, input().split())), reverse=True)
MOD = 10 ** 9 + 7
X_sum = 0
for (i, x) in enumerate(X, start=1):
	X_sum += x * (N - i - i + 1)
	X_sum %= MOD
Y_sum = 0
for (i, y) in enumerate(Y, start=1):
	Y_sum += y * (M - i - i + 1)
	Y_sum %= MOD
print(X_sum * Y_sum % MOD)


(N, M) = map(int, input().split())
MOD = 10 ** 9 + 7
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
Xsum = 0
for i in range(1, N + 1):
	Xsum += X[i - 1] * i - (N - i + 1) * X[i - 1]
	Xsum %= MOD
Ysum = 0
for i in range(1, M + 1):
	Ysum += Y[i - 1] * i - (M - i + 1) * Y[i - 1]
	Ysum %= MOD
print(Xsum * Ysum % MOD)


(x, y) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
(A, B) = (sorted(A)[::-1], sorted(B)[::-1])
mod = 10 ** 9 + 7
(X, Y) = (0, 0)
for i in range(x):
	d = A[i] * (x - i) - A[i] * i - A[i]
	X += d
	X %= mod
for i in range(y):
	d = B[i] * (y - i) - B[i] * i - B[i]
	Y += d
	Y %= mod
print(X * Y % mod)


(n, m) = map(int, input().split(' '))
X = list(map(int, input().split(' ')))
Y = list(map(int, input().split(' ')))
mod = 10 ** 9 + 7
sum_x = sum_y = 0
l = 0
r = n - 1
while l < r:
	sum_x += (r - l) * abs(X[r] - X[l])
	r -= 1
	l += 1
l = 0
r = m - 1
while l < r:
	sum_y += (r - l) * abs(Y[r] - Y[l])
	r -= 1
	l += 1
print(sum_x * sum_y % mod)


MOD = 10 ** 9 + 7

class Fp(int):

	def __new__(self, x=0):
		return super().__new__(self, x % MOD)

	def inv(self):
		return self.__class__(super().__pow__(MOD - 2, MOD))

	def __add__(self, value):
		return self.__class__(super().__add__(value))

	def __sub__(self, value):
		return self.__class__(super().__sub__(value))

	def __mul__(self, value):
		return self.__class__(super().__mul__(value))

	def __floordiv__(self, value):
		return self.__class__(self * self.__class__(value).inv())

	def __pow__(self, value):
		return self.__class__(super().__pow__(value % (MOD - 1), MOD))
	__radd__ = __add__
	__rmul__ = __mul__

	def __rsub__(self, value):
		return self.__class__(-super().__sub__(value))

	def __rfloordiv__(self, value):
		return self.__class__(self.inv() * value)

	def __iadd__(self, value):
		self = self + value
		return self

	def __isub__(self, value):
		self = self - value
		return self

	def __imul__(self, value):
		self = self * value
		return self

	def __ifloordiv__(self, value):
		self = self // value
		return self

	def __ipow__(self, value):
		self = self ** value
		return self

	def __neg__(self):
		return self.__class__(super().__neg__())
import sys
sys.stdin.readline

def main():
	(n, m) = map(int, input().split())
	X = list(map(int, input().split()))
	Y = list(map(int, input().split()))
	n = Fp(n)
	m = Fp(m)
	print(sum(((n - i) * i * (X[i] - X[i - 1]) for i in range(1, n))) * sum(((m - i) * i * (Y[i] - Y[i - 1]) for i in range(1, m))))

def __starting_point():
	main()
__starting_point()


import sys
input = sys.stdin.readline
MOD = 10 ** 9 + 7

def f(l):
	ret = 0
	for k in range(len(l)):
		ret += (2 * (k + 1) - len(l) - 1) * l[k]
	return ret % MOD

def main():
	(n, m) = map(int, input().split())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	ans = f(x) * f(y) % MOD
	print(ans)

def __starting_point():
	main()
__starting_point()


(N, M) = map(int, input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
P = 10 ** 9 + 7
X = 0
Y = 0
for i in range(1, N + 1):
	X += x[i - 1] * (2 * i - 1 - N)
	X = X % P
for j in range(1, M + 1):
	Y += y[j - 1] * (2 * j - 1 - M)
	Y = Y % P
print(X * Y % P)


(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
ans = 0

def sum_S(a, z):
	ans = 0
	for i in range(len(z)):
		z_i = z[i] * (2 * i + 1 - a)
		ans += z_i
	return ans
ans_x = sum_S(n, x)
ans_y = sum_S(m, y)
res = ans_x * ans_y % mod
print(res)


(a, b) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
s = 0
k = 0
for (i, t) in enumerate(reversed(x)):
	s += (a - i - 1) * t
	s -= i * t
for (i, t) in enumerate(reversed(y)):
	k += (b - i - 1) * t
	k -= i * t
print(s * k % (10 ** 9 + 7))


(n, m) = map(int, input().split())
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
x_sum = 0
y_sum = 0
for i in range(1, n + 1):
	x_sum += X[i - 1] * (i - 1) - X[i - 1] * (n - i)
for i in range(1, m + 1):
	y_sum += Y[i - 1] * (i - 1) - Y[i - 1] * (m - i)
print(x_sum * y_sum % 1000000007)


def main():
	MOD = 10 ** 9 + 7
	(N, M) = list(map(int, input().split()))
	(*x,) = list(map(int, input().split()))
	(*y,) = list(map(int, input().split()))
	sx = 0
	for (i, x_) in enumerate(x, 1):
		sx = (sx + x_ * (i - 1 - (N - i))) % MOD
	sy = 0
	for (i, y_) in enumerate(y, 1):
		sy = (sy + y_ * (i - 1 - (M - i))) % MOD
	ans = sx * sy % MOD
	print(ans)

def __starting_point():
	main()
__starting_point()


MOD = 10 ** 9 + 7
(n, m) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
X.sort()
Y.sort()
(xx, yy) = (0, 0)
for i in range(n):
	xx += X[i] * i
	xx -= X[i] * (n - i - 1)
for i in range(m):
	yy += Y[i] * i
	yy -= Y[i] * (m - i - 1)
print(xx * yy % MOD)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
P = 10 ** 9 + 7

def s(n, i):
	return i * (n - (i - 1))

def xx(x, n):
	t = 0
	for i in range(n - 1):
		t = (t + s(n - 1, i + 1) * (x[i + 1] - x[i])) % P
	return t
R = xx(x, n) * xx(y, m) % P
print(R)


import sys

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

def mapint():
	return map(int, input().split())
sys.setrecursionlimit(10 ** 9)
(N, M) = mapint()
mod = 10 ** 9 + 7
Xs = list(mapint())
Ys = list(mapint())
xsum = 0
for i in range(N):
	x = Xs[i]
	xsum += i * x - (N - i - 1) * x
	xsum %= mod
ysum = 0
for i in range(M):
	y = Ys[i]
	ysum += i * y - (M - i - 1) * y
	ysum %= mod
print(xsum * ysum % mod)


MOD = int(10 ** 9 + 7)
(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x_mul = 0
y_mul = 0
for i in range(n):
	x_mul += (i - (n - i - 1)) * x[i] % MOD
for i in range(m):
	y_mul += (i - (m - i - 1)) * y[i] % MOD
print(x_mul * y_mul % MOD)


def wa(ka, li):
	t = 0
	i = 0
	while ka > 0:
		t = (t + (li[-(i + 1)] - li[i]) * (ka - 1)) % (10 ** 9 + 7)
		ka -= 2
		i += 1
	return t
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
print(wa(n, x) * wa(m, y) % (10 ** 9 + 7))


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
sx = 0
sy = 0
pr = 10 ** 9 + 7
for i in range(1, n):
	sx += (x[i] - x[i - 1]) * (i * (n - i)) % pr
for i in range(1, m):
	sy += (y[i] - y[i - 1]) * (i * (m - i)) % pr
print(sx * sy % pr)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
mod = 10 ** 9 + 7
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
ans_x = 0
ans_y = 0
for (i, xi) in enumerate(x):
	ans_x += i * xi - (n - 1 - i) * xi
	ans_x %= mod
for (j, yi) in enumerate(y):
	ans_y += j * yi - (m - 1 - j) * yi
	ans_y %= mod
print(ans_x * ans_y % mod)


MOD = 10 ** 9 + 7

def main():
	(n, m) = map(int, input().split())
	(n, m) = (n - 1, m - 1)
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	(a, b) = (0, 0)
	for i in range(n):
		tmp = x[i + 1] - x[i]
		tmp *= (1 + i) * (n - i) % MOD
		a += tmp
		a %= MOD
	for i in range(m):
		tmp = y[i + 1] - y[i]
		tmp *= (1 + i) * (m - i) % MOD
		b += tmp
		b %= MOD
	print(a * b % MOD)

def __starting_point():
	main()
__starting_point()


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
X = sum([(2 * (k + 1) - n - 1) * x[k] for k in range(n)])
Y = sum([(2 * (k + 1) - m - 1) * y[k] for k in range(m)])
print(X * Y % (10 ** 9 + 7))


(n, m) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
sum_x = 0
sum_y = 0
for i in range(n):
	sum_x += (n - 1 - i * 2) * X[i]
for i in range(m):
	sum_y += (m - 1 - i * 2) * Y[i]
sum_x = sum_x % MOD
sum_y = sum_y % MOD
print(sum_x * sum_y % MOD)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.sort(reverse=True)
y.sort(reverse=True)
s = sum((x[i] * (n - 1 - 2 * i) for i in range(n)))
t = sum((y[i] * (m - 1 - 2 * i) for i in range(m)))
print(s * t % (10 ** 9 + 7))


Q = 10 ** 9 + 7

def zen(A, k):
	jiku = 0
	for i in range(k):
		jiku += i * A[i] - (k - 1 - i) * A[i]
	return jiku % Q
(n, m) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
ans = zen(X, n) * zen(Y, m)
ans %= Q
print(ans)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
(width, height) = (0, 0)
a = -n - 1
for k in range(1, n + 1):
	width += x[k - 1] * (2 * k + a)
a = -m - 1
for k in range(1, m + 1):
	height += y[k - 1] * (2 * k + a)
width %= 1000000007
height %= 1000000007
print(width * height % 1000000007)


import sys
readline = sys.stdin.readline
(N, M) = map(int, readline().split())
X = list(map(int, readline().split()))
Y = list(map(int, readline().split()))
DIV = 10 ** 9 + 7

def f(V):
	vsum = 0
	for i in range(1, len(V)):
		vsum += (V[i] - V[i - 1]) % DIV * (i * (len(V) - i) % DIV) % DIV
		vsum %= DIV
	return vsum
print(f(X) * f(Y) % DIV)


(N, M) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
x_diff = 0
y_diff = 0
for i in range(N):
	x_diff += (2 * i - N + 1) * X[i] % MOD
for i in range(M):
	y_diff += (2 * i - M + 1) * Y[i] % MOD
print(x_diff * y_diff % MOD)


import numpy as np

def main():
	mod = 10 ** 9 + 7
	(n, m) = list(map(int, input().split()))
	X = np.array(list(map(int, input().split())), dtype=np.int64)
	Y = np.array(list(map(int, input().split())), dtype=np.int64)
	dxs = X[1:] - X[:-1]
	left = np.arange(1, n)
	right = np.arange(n - 1, 0, -1)
	x_pattern = left * right % mod
	x_sum = (dxs * x_pattern).sum() % mod
	dys = Y[1:] - Y[:-1]
	up = np.arange(1, m)
	down = np.arange(m - 1, 0, -1)
	y_pattern = up * down % mod
	y_sum = (dys * y_pattern).sum() % mod
	print(x_sum * y_sum % mod)

def __starting_point():
	main()
__starting_point()


(n, m) = map(int, input().split())
xsum = 0
xx = [int(i) for i in input().split()]
for (i, x) in enumerate(xx):
	xsum += (2 * i - n + 1) * x
ysum = 0
yy = [int(i) for i in input().split()]
for (i, y) in enumerate(yy):
	ysum += (2 * i - m + 1) * y
print(xsum * ysum % 1000000007)


(N, M) = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
B = [int(_) for _ in input().split()]
mod = 10 ** 9 + 7
X = 0
Y = 0
for i in range(N - 1):
	X += (A[i + 1] - A[i]) * (i + 1) * (N - 1 - i)
	X %= mod
for j in range(M - 1):
	Y += (B[j + 1] - B[j]) * (j + 1) * (M - 1 - j)
	Y %= mod
print(X * Y % mod)


(n, m) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
x = []
MOD = 10 ** 9 + 7
for i in range(n - 1):
	x.append(X[i + 1] - X[i])
y = []
for i in range(m - 1):
	y.append(Y[i + 1] - Y[i])
xlen = 0
for i in range(n - 1):
	xlen += (i + 1) * ((n - i - 1) * x[i]) % MOD % MOD
ylen = 0
for j in range(m - 1):
	ylen += (j + 1) * ((m - j - 1) * y[j]) % MOD % MOD
print(xlen * ylen % MOD)


(N, M) = list(map(int, input().split()))
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
mod = int(1000000000.0 + 7)
X.sort(reverse=True)
Y.sort(reverse=True)
(XP, YP) = (0, 0)
for i in range(N):
	XP += (N - 1 - i * 2) * X[i]
	XP %= mod
for i in range(M):
	YP += (M - 1 - i * 2) * Y[i]
	YP %= mod
print(XP * YP % mod)


(n, m) = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]
y = [int(x) for x in input().split()]
mod = 10 ** 9 + 7
ans = 0
ysum = 0
for j in range(1, m):
	ysum += (y[j] - y[j - 1]) * j * (m - j)
for i in range(1, n):
	ans = ans + (x[i] - x[i - 1]) * i * (n - i) * ysum
print(ans % mod)


(N, M) = map(int, input().split())
MOD = 10 ** 9 + 7
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
sumX = 0
sumY = 0
for (i, x) in enumerate(X):
	sumX += -(N - (i + 1)) * x + i * x
	sumX %= MOD
for (i, y) in enumerate(Y):
	sumY += -(M - (i + 1)) * y + i * y
	sumX %= MOD
ans = sumX * sumY % MOD
print(ans)


mod = 1000000007
(n, m) = map(int, input().split())
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
xc = 0
for i in range(1, n):
	a = x[i] - x[i - 1]
	if i <= n // 2:
		l = i
	else:
		l = n - i
	xc += a * (l * n - l * l)
	xc = xc % mod
yc = 0
for i in range(1, m):
	a = y[i] - y[i - 1]
	if i <= m // 2:
		l = i
	else:
		l = m - i
	yc += a * (l * m - l * l)
	yc = yc % mod
print(xc * yc % mod)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
a = [x[i + 1] - x[i] for i in range(n - 1)]
b = [y[i + 1] - y[i] for i in range(m - 1)]
MOD = int(1000000000.0 + 7)
ai = sum([a[i] * (i + 1) * max((0, n - 1 - i)) % MOD for i in range(n - 1)])
bi = sum([b[i] * (i + 1) * max((0, m - 1 - i)) % MOD for i in range(m - 1)])
ans = ai * bi % MOD
print(ans)


(n, m) = input().split()
n = int(n)
m = int(m)
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]

def sum(a, n):
	sum_a = 0
	for i in range(0, n):
		sum_a += i * a[i] - (n - 1 - i) * a[i]
	return sum_a
sum_x = sum(x, n)
sum_y = sum(y, m)
s = sum_x * sum_y % (10 ** 9 + 7)
print(s)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
x0 = 0
for i in range(n - 1):
	x0 += (x[i + 1] - x[i]) * (i + 1) * (n - i - 1)
	x0 %= mod
y0 = 0
for i in range(m - 1):
	y0 += (y[i + 1] - y[i]) * (i + 1) * (m - i - 1)
	y0 %= mod
print(x0 * y0 % mod)


p = 10 ** 9 + 7
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
w = [(x[i + 1] - x[i]) * (1 + i) * (n - i - 1) % p for i in range(n - 1)]
y = list(map(int, input().split()))
h = [(y[k + 1] - y[k]) * (1 + k) * (m - k - 1) % p for k in range(m - 1)]
print(sum(w) % p * (sum(h) % p) % p)


import sys
input = sys.stdin.readline
mod = 10 ** 9 + 7
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
xsum = 0
for i in range(n):
	xsum += x[-i - 1] * (n - 2 * i - 1) % mod
ysum = 0
for i in range(m):
	ysum += y[-i - 1] * (m - 2 * i - 1) % mod
print(xsum * ysum % mod)


def d_igeta(N, M, X, Y):
	tmp1 = 0
	tmp2 = 0
	for (k, x) in enumerate(X):
		k += 1
		tmp1 += (k - 1) * x - (N - k) * x
	for (k, y) in enumerate(Y):
		k += 1
		tmp2 += (k - 1) * y - (M - k) * y
	return tmp1 * tmp2 % (10 ** 9 + 7)
(N, M) = [int(i) for i in input().split()]
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]
print(d_igeta(N, M, X, Y))


(n, m) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
xsum = 0
ysum = 0
mod = 10 ** 9 + 7
for (i, x) in enumerate(X):
	xsum += x * (i - (n - 1 - i))
for (i, y) in enumerate(Y):
	ysum += y * (i - (m - 1 - i))
print(xsum * ysum % mod)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
s = 0
t = 0
p = 10 ** 9 + 7
for i in range(n):
	s = (s - (n - 1 - 2 * i) * x[i]) % p
for i in range(m):
	t = (t - (m - 1 - 2 * i) * y[i]) % p
print(s * t % p)


import sys
input = sys.stdin.readline
(N, M) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
mod = 10 ** 9 + 7
A = 0
for i in range(N - 1):
	A += (X[i + 1] - X[i]) * ((i + 1) * (N - 1 - i)) % mod
	A %= mod
B = 0
for j in range(M - 1):
	B += (Y[j + 1] - Y[j]) * ((j + 1) * (M - 1 - j)) % mod
	B %= mod
print(A * B % mod)


mod = 10 ** 9 + 7

def f(a):
	c = 0
	for i in range(len(a)):
		c += a[i] - a[0]
	d = c
	for i in range(1, len(a) - 1):
		d += c - (len(a) - i) * (a[i] - a[i - 1])
		c -= (len(a) - i) * (a[i] - a[i - 1])
	return d % mod
(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(f(a) * f(b) % mod)


(n, m) = map(int, input().split())
xs = list(map(int, input().split()))
ys = list(map(int, input().split()))
w = 0
for i in range(1, n):
	w += i * (n - i) * (xs[i] - xs[i - 1])
h = 0
for i in range(1, m):
	h += i * (m - i) * (ys[i] - ys[i - 1])
r = w * h % 1000000007
print(r)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
ax = sum([(2 * i - n + 1) * x[i] for i in range(n)])
ay = sum([(2 * i - m + 1) * y[i] for i in range(m)])
print(ax * ay % (10 ** 9 + 7))


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7

def main(n, x, mod):
	w = 0
	for i in range(1, n):
		w += (x[i] - x[i - 1]) * i * (n - i)
		w %= mod
	return w
print(main(n, x, mod) * main(m, y, mod) % mod)


mod = 10 ** 9 + 7
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.sort()
y.sort()
xd = 0
for i in range(n):
	xd += (2 * i - n + 1) * x[i]
	xd %= mod
yd = 0
for i in range(m):
	yd += (2 * i - m + 1) * y[i]
	yd %= mod
print(xd * yd % mod)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = int(1000000000.0) + 7
S = 0
for i in range(n):
	S += (2 * i + 1 - n) * x[i]
	S %= mod
T = 0
for j in range(m):
	T += (2 * j + 1 - m) * y[j]
	T %= mod
print(S * T % mod)


import sys

def main():
	p = 10 ** 9 + 7

	def totsum(l, n):
		s = 0
		t = 0
		for i in range(n // 2):
			t = t + l[-1 - i] - l[i]
			s = (s + t) % p
		s = (2 * s - (1 - n & 1) * t) % p
		return s
	(n, m) = list(map(int, input().split()))
	x = list(map(int, sys.stdin.readline().strip().split()))
	y = list(map(int, sys.stdin.readline().strip().split()))
	print(totsum(x, n) * totsum(y, m) % p)

def __starting_point():
	main()
__starting_point()


I = lambda : [int(i) for i in input().split()]
(n, m) = I()
N = I()
M = I()
F = lambda x, y: sum((j * (y - 1 - 2 * i) for (i, j) in enumerate(x)))
print(F(N, n) * F(M, m) % (10 ** 9 + 7))


(x, y) = [int(i) for i in input().split()]
xl = [int(i) for i in input().split()]
yl = [int(i) for i in input().split()]
xx = sum([i * xl[i] - (x - i - 1) * xl[i] for i in range(len(xl))])
yy = sum([i * yl[i] - (y - i - 1) * yl[i] for i in range(len(yl))])
ans = xx * yy % (10 ** 9 + 7)
print(ans)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = pow(10, 9) + 7
(a, b) = ([0] * (n - 1), [0] * (m - 1))
(c, s) = (n - 1, 0)
for i in range(n - 1):
	s += c
	a[i] = s
	c -= 2
(c, s) = (m - 1, 0)
for i in range(m - 1):
	s += c
	b[i] = s
	c -= 2
(sumx, sumy) = (0, 0)
for i in range(n - 1):
	sumx += a[i] * (x[i + 1] - x[i])
	sumx %= mod
for i in range(m - 1):
	sumy += b[i] * (y[i + 1] - y[i])
	sumy %= mod
ans = sumx * sumy % mod
print(ans)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
x.sort()
y.sort()
(sx, sy) = (0, 0)
for k in range(1, n + 1):
	sx += (2 * k - n - 1) * x[k - 1]
	sx %= mod
for k in range(1, m + 1):
	sy += (2 * k - m - 1) * y[k - 1]
	sy %= mod
print(sx * sy % mod)


from itertools import product, combinations
MOD = 10 ** 9 + 7

def solve(X, Y):
	DX = [a - b for (a, b) in zip(X[1:], X)]
	DY = [a - b for (a, b) in zip(Y[1:], Y)]
	a = sum(((i + 1) * (len(DX) - i) * dx for (i, dx) in enumerate(DX)))
	b = sum(((i + 1) * (len(DY) - i) * dy for (i, dy) in enumerate(DY)))
	return a * b % MOD

def naive(X, Y):
	a = 0
	for ((x1, x2), (y1, y2)) in product(combinations(X, 2), combinations(Y, 2)):
		a += (x2 - x1) * (y2 - y1)
		a %= MOD
	return a
from random import randrange
from itertools import accumulate

def test():
	for _ in range(10000):
		X = list(accumulate([randrange(1, 8) for _ in range(3)]))
		Y = list(accumulate([randrange(1, 8) for _ in range(2)]))
		a1 = solve(X, Y)
		a2 = naive(X, Y)
		if a1 != a2:
			print((X, Y))
			print(a1)
			print(a2)
			return

def __starting_point():
	(N, M) = list(map(int, input().split()))
	X = tuple(map(int, input().split()))
	Y = tuple(map(int, input().split()))
	print(solve(X, Y))
__starting_point()


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
(sidex, sidey) = (0, 0)
for i in range(1, n):
	sidex += (x[i] - x[i - 1]) * i * (n - i) % mod
for i in range(1, m):
	sidey += (y[i] - y[i - 1]) * i * (m - i) % mod
print(sidex * sidey % mod)


import sys

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

def LI():
	return list(map(int, sys.stdin.readline().rstrip().split()))
(N, M) = MI()
(X, Y) = (LI(), LI())
mod = 10 ** 9 + 7
r = sum((i * (N - i) * (X[i] - X[i - 1]) % mod for i in range(1, N)))
r %= mod
ans = 0
for i in range(1, M):
	ans += r * i * (M - i) * (Y[i] - Y[i - 1]) % mod
	ans %= mod
print(ans)


(n, m) = map(int, input().split())
INF = 10 ** 9 + 7

def F(j, i):
	return i * (j - i) % INF
dx = []
px = 0
sx = 0
for x in map(int, input().split()):
	dx.append(x - px)
	px = x
dy = []
py = 0
sy = 0
for y in map(int, input().split()):
	dy.append(y - py)
	py = y
for i in range(1, n):
	sx = (sx + dx[i] * F(n, i) % INF) % INF
for i in range(1, m):
	sy = (sy + dy[i] * F(m, i) % INF) % INF
print(sx * sy % INF)


import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
	(N, M) = map(int, input().split())
	X = list(map(int, input().split()))
	Y = list(map(int, input().split()))
	height = sum(((Y[i + 1] - Y[i]) * (i + 1) * (M - i - 1) % MOD for i in range(M - 1))) % MOD
	ans = sum((height * (X[i + 1] - X[i]) * (i + 1) * (N - i - 1) % MOD for i in range(N - 1))) % MOD
	print(ans)

def __starting_point():
	main()
__starting_point()


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
xlen = 0
ylen = 0
for i in range(1, n):
	xlen += i * (n - i) * (x[i] - x[i - 1])
for i in range(1, m):
	ylen += i * (m - i) * (y[i] - y[i - 1])
print(xlen * ylen % (10 ** 9 + 7))


mod = 10 ** 9 + 7

def mod_mul(a, b):
	return a * b % mod
(N, M) = map(int, input().split())
(*x,) = map(int, input().split())
(*y,) = map(int, input().split())
sx = sum((mod_mul(_x, i - (N - 1 - i)) for (i, _x) in enumerate(x)))
sy = sum((mod_mul(_y, i - (M - 1 - i)) for (i, _y) in enumerate(y)))
print(sx * sy % mod)


(N, M) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
tmpX = 0
for i in range(N):
	tmpX += (2 * (i + 1) - N - 1) * X[i] % MOD
	tmpX %= MOD
tmpY = 0
for i in range(M):
	tmpY += (2 * (i + 1) - M - 1) * Y[i] % MOD
	tmpY %= MOD
print(tmpX * tmpY % MOD)


(N, M) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
mod = 10 ** 9 + 7
XS = 0
for (i, x) in enumerate(X, start=1):
	XS += x * (i - 1 - (N - i)) % mod
YS = 0
for (i, y) in enumerate(Y, start=1):
	YS += y * (i - 1 - (M - i)) % mod
print(XS * YS % mod)


(n, m) = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
MOD = 10 ** 9 + 7

def calc(lis):
	num = len(lis)
	sum = 0
	for i in range(num):
		sum += lis[i] * i - lis[i] * (num - i - 1)
	return sum
xSum = calc(x)
ySum = calc(y)
ans = xSum * ySum % MOD
print(ans)


(N, M) = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
mod = 10 ** 9 + 7
vx = sum(((2 * (k + 1) - N - 1) * X[k] % mod for k in range(N))) % mod
vy = sum(((2 * (k + 1) - M - 1) * Y[k] % mod for k in range(M))) % mod
print(vx * vy % mod)


MOD = 10 ** 9 + 7
(n, m) = map(int, input().split())
x = sorted(map(int, input().split()))
y = sorted(map(int, input().split()))
(X, Y) = (0, 0)
for i in range(n):
	X = X + x[i] * (i + 1) % MOD
	X = (X - x[i] * (n - i) + MOD) % MOD
for k in range(m):
	Y = Y + y[k] * (k + 1) % MOD
	Y = (Y - y[k] * (m - k) % MOD + MOD) % MOD
print(X * Y % MOD)


mod = 10 ** 9 + 7

def sum_interval_1d(N, X):
	X_ = [X[i + 1] - X[i] for i in range(N - 1)]
	coef = list(range(1, N))[::-1]
	ret = X_[0] * coef[0] % mod
	for i in range(1, N - 1):
		coef[i] = (coef[i] + coef[i - 1] - i) % mod
		ret = (ret + X_[i] * coef[i] % mod) % mod
	return ret

def solve():
	(N, M) = map(int, input().split())
	X = list(map(int, input().split()))
	Y = list(map(int, input().split()))
	x_sum = sum_interval_1d(N, X)
	y_sum = sum_interval_1d(M, Y)
	ret = x_sum * y_sum % mod
	print(ret)
solve()


(n, m) = map(int, input().split())
xl = list(map(int, input().split()))
yl = list(map(int, input().split()))
xl = list(map(lambda x: x - xl[0], xl))
yl = list(map(lambda x: x - yl[0], yl))
xi = 0
yi = 0
mod = 10 ** 9 + 7
xsum = sum(xl)
ysum = sum(yl)
for i in range(n):
	xi += (xsum - xl[i] * (n - i)) % mod
	xsum -= xl[i]
for j in range(m):
	yi += (ysum - yl[j] * (m - j)) % mod
	ysum -= yl[j]
print(xi * yi % mod)


(n, m) = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
MOD = 10 ** 9 + 7
xx = 0
yy = 0
for (i, xi) in enumerate(x):
	xx += (2 * i + 1 - n) * xi
for (i, yi) in enumerate(y):
	yy += (2 * i + 1 - m) * yi
print(xx * yy % MOD)