atcoder#ARC071B. [ABC058D] 井井井

[ABC058D] 井井井

Score : 500500 points

Problem Statement

On a two-dimensional plane, there are mm lines drawn parallel to the xx axis, and nn lines drawn parallel to the yy axis. Among the lines parallel to the xx axis, the ii-th from the bottom is represented by y=yiy = y_i. Similarly, among the lines parallel to the yy axis, the ii-th from the left is represented by x=xix = x_i.

For every rectangle that is formed by these lines, find its area, and print the total area modulo 109+710^9+7.

That is, for every quadruple (i,j,k,l)(i,j,k,l) satisfying 1i<jn1\leq i < j\leq n and 1k<lm1\leq k < l\leq m, find the area of the rectangle formed by the lines x=xix=x_i, x=xjx=x_j, y=yky=y_k and y=yly=y_l, and print the sum of these areas modulo 109+710^9+7.

Constraints

  • 2n,m1052 \leq n,m \leq 10^5
  • 109x1<...<xn109-10^9 \leq x_1 < ... < x_n \leq 10^9
  • 109y1<...<ym109-10^9 \leq y_1 < ... < y_m \leq 10^9
  • xix_i and yiy_i are integers.

Input

Input is given from Standard Input in the following format:

nn mm

x1x_1 x2x_2 ...... xnx_n

y1y_1 y2y_2 ...... ymy_m

Output

Print the total area of the rectangles, modulo 109+710^9+7.

3 3
1 3 4
1 3 6
60

The following figure illustrates this input:

sample1-1

The total area of the nine rectangles A, B, ..., I shown in the following figure, is 6060.

sample1-2

6 5
-790013317 -192321079 95834122 418379342 586260100 802780784
-253230108 193944314 363756450 712662868 735867677
835067060