n, m = map(int, raw_input().split())
x = map(int, raw_input().split())
y = map(int, raw_input().split())

result = (max(x) - min(x)) * (max(y) - min(y))
result *= ((n - 2) * (m - 2))

print(result % (10**9 + 7))