n, m = map(int, input().split(" "));
xs = list(map(int, input().split(" ")));
ys = list(map(int, input().split(" ")));
modula=1000000007

sumx=0;
for i in range(0, n-1):
    for j in range(i+1, n):
        sumx += (xs[j]-xs[i]) % modula

sumy=0;
for i in range(0, m-1):
    for j in range(i+1, m):
        sumy += (ys[j]-ys[i]) % modula

big, small = sumx, sumy;
if big < small:
    big, small = small, big;

delta = modula // big;

answer = 0;
while True:
    answer += (delta*big) % modula;
    small -= delta;
    if small<delta:
        break;

answer += small*big % modula;
print(answer);
