n, m = [int(x) for x in input().split(' ')]
hor = [int(x) for x in input().split(' ')]
ver = [int(x) for x in input().split(' ')]
area = 0
for i in range(n-1):
    stor = 0
    for j in range(m-1):
        stor += (hor[i+1] - hor[i]) * (ver[j+1] - ver[j]) * (j+1) * (n-j-1)
    area += stor * (i + 1) * (n-i-1)
    area = area % (10**9 + 7)
print(area)
