from math import ceil def floor_sum_of_linear(L: int, R: int, a: int, b: int, mod: int) -> int: """ ``` sum((x * a + b) // mod for x in range(L, R)) ``` """ if L >= R: return 0 res = 0 b += L * a n = R - L if b < 0: k = ceil(-b / mod) b += k * mod res -= n * k while n: q, a = a // mod, a % mod res += n * (n - 1) // 2 * q if b >= mod: q, b = b // mod, b % mod res += n * q n, b = (a * n + b) // mod, (a * n + b) % mod a, mod = mod, a return res if __name__ == "__main__": import sys sys.setrecursionlimit(int(1e9)) input = lambda: sys.stdin.readline().rstrip("\r\n") N = int(input()) M = int(input()) A = list(map(int, input().split())) B = list(map(int, input().split())) ans = 0 for a in A: for b in B: ans += floor_sum_of_linear(1, b + 1, a, 0, b) ans *= 2 ans %= int(1e9 + 7) print(ans)