City Influence

No attempts yetTime limit2sMemory limit64 MB

Problem

A new city is being built. Seen from above the city is a plane, and that plane is cut into 109×10910^9 \times 10^9 cells of equal size. The top left cell is (1,1)(1, 1) and the bottom right cell is (109,109)(10^9, 10^9). Every cell carries a number that records the influence on that cell, and every number starts at 00.

The city will contain many public facilities, so before construction the planners estimated the influence each facility spreads around it. One estimate has this form.

  • Add pp to every cell (x,y)(x, y) with axca \le x \le c and bydb \le y \le d.

After all estimates are applied, the influence of one cell is the square of the number written on it, and the influence of the city is the sum of the influence of all cells.

Suppose there are these two estimates.

  • Add 11 to every cell (x,y)(x, y) with 1x21 \le x \le 2 and 1y31 \le y \le 3.
  • Add 22 to every cell (x,y)(x, y) with 1x31 \le x \le 3 and 2y32 \le y \le 3.

Cells (1,1)(1, 1) and (2,1)(2, 1) then hold 11, cells (1,2)(1, 2), (1,3)(1, 3), (2,2)(2, 2), (2,3)(2, 3) hold 33, cells (3,2)(3, 2) and (3,3)(3, 3) hold 22, and every other cell holds 00. The influence of the city is 12×2+32×4+22×2=461^2 \times 2 + 3^2 \times 4 + 2^2 \times 2 = 46.

Given NN estimates, write a program that computes the influence of the city after all of them are applied.

Input

The first line contains the number of estimates NN (1N1051 \le N \le 10^5).

Each of the next NN lines contains aa, bb, cc, dd, pp (1ac1091 \le a \le c \le 10^9, 1bd1091 \le b \le d \le 10^9, 1p1001 \le p \le 100) separated by spaces. Each line is one estimate as described above.

Output

Print the influence of the city after all estimates are applied. The answer can be very large, so print it modulo 1,000,000,007.