from itertools import combinations

n, m = [int(i) for i in input().split(' ')]
x_list = [int(i) for i in input().split(' ')]
y_list = [int(i) for i in input().split(' ')]

total = 0
for x1, x2 in combinations(x_list, 2):
    for y1, y2 in combinations(y_list,2):
        total += (x2-x1)*(y2-y1)
        
print(int(total % (10**9+2)))