Alice has an grid. The cell at row and column has a value .
Alice builds a 2D plane by repeating the grid infinite times. In other words, ... equal to ... , as well as ... , ... , etc.
Alice would like to calculate the sum of the values of a rectangle inside the infinite 2D plane . Given , , and which represent the edges of the rectangle in , please help Alice to find the sum of values of the rectangle. As the answer may be too large, output your answer modulo .
Input
第一行包含兩個整數, 和 。
接下來的 行各包含 個整數,代表網格中的數值。對於第 行, 個整數分別代表 到 。
最後一行包含四個整數,、、 和 。
The first line contains two integers, and .
The following lines each contains integers, representing the values in the grid. For line , the integers represent to respectively.
The final line contains four integers, , , and .
Output
輸出一個整數,即二維平面 中從行 到 (含),列 到 (含)的矩形的數值之和,對 取模。
Output one single integer, the sum of values of the rectangle from row to (inclusive), column to (inclusive) in the 2D plane , modulo .