n, m = map(int, input().split())
x = [x for x in map(int, input().split())]
y = [y for y in map(int, input().split())]
ans = 0
for i in range(n-1):
    for j in range(m-1):
        v = (i+1)*(n-1-i) * (j+1)*(m-1-j) #面積係数
        x_width = x[i+1] - x[i]
        y_width = y[j+1] - y[j]
        ans += v * x_width * y_width #面積係数*最小長方形面積
print(ans%1000000007)