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

ret = 0
for i in range(1, m) :
    for j in range(1, n) :
        ret += (x[j]-x[j-1])*(y[i]-y[i-1])*(n-j)*(m-i)*i*j%MOD
        ret %= MOD
        
print(ret)
