# -*- coding: utf-8 -*-


n,m = map(int,input().split())

x = list(map(int,input().split()))
y = list(map(int,input().split()))

ans = (((x[-1] - x[0]) * (y[-1]-y[0]) * (n+m-2)) )% (pow(10,9)+7)

print(ans)