a = list(map(int,input().split()))
x = list(map(int,input().split()))
y = list(map(int,input().split()))
xx = x[-1]-x[0]
x1 = (a[0]-1) * xx
yy = y[-1]-y[0]
y1 = (a[1]-1) * yy
x1 = x1%((10**9)+7)
y1 = y1%((10**9)+7)
print((x1*y1)%((10**9)+7))