atcoder#ARC071B. [ABC058D] 井井井
[ABC058D] 井井井
Score : points
Problem Statement
On a two-dimensional plane, there are lines drawn parallel to the axis, and lines drawn parallel to the axis. Among the lines parallel to the axis, the -th from the bottom is represented by . Similarly, among the lines parallel to the axis, the -th from the left is represented by .
For every rectangle that is formed by these lines, find its area, and print the total area modulo .
That is, for every quadruple satisfying and , find the area of the rectangle formed by the lines , , and , and print the sum of these areas modulo .
Constraints
- and are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the total area of the rectangles, modulo .
3 3
1 3 4
1 3 6
60
The following figure illustrates this input:
The total area of the nine rectangles A, B, ..., I shown in the following figure, is .
6 5
-790013317 -192321079 95834122 418379342 586260100 802780784
-253230108 193944314 363756450 712662868 735867677
835067060