num = input().split()
vertical = input().split()
horizontal = input().split()

xmin = 10**9
xmax = -10**9
ymin = 10**9
ymax = -10**9

for i in range(int(num[0])):
	xmin = min(int(vertical[i]), xmin)
	xmax = max(int(vertical[i]), xmax)
for i in range(int(num[1])):
	ymin = min(int(horizontal[i]), ymin)
	ymax = max(int(horizontal[i]), ymax)

ans = ((xmax - xmin) * (ymax - ymin) * (int(num[0])-1) * (int(num[1])-1)) % (10**9 + 7)

print(ans)