
if __name__ == "__main__":
    n, m = map(int, input().split())
    x = list(map(int, input().split()))
    y = list(map(int, input().split()))

    S = ((n - 1) * (m - 1) * (max(x) - min(x)) * (max(y) - min(y))) 
    print(S % (10 ** 9 + 7))