#P11621. Weighted Point Operations

    ID: 13716 Type: Default 1000ms 256MiB

Weighted Point Operations

Weighted Point Operations

You are given a plane with integer coordinates, where each lattice point initially has a weight of 0. There are a total of mm operations. There are two types of operations:

  1. Modification Operation: Given integers xx, yy, dd, and ww, increase the weight of every lattice point (X,Y)(X,Y) satisfying
Xx,  Yy,  X+Y<x+y+dX \ge x, \; Y \ge y, \; X+Y < x+y+d

by ww.

  1. Query Operation: Given integers x1x_1, x2x_2, y1y_1, and y2y_2, compute the sum of weights of all lattice points (X,Y)(X,Y) satisfying
x1Xx2,  y1Yy2,x_1 \le X \le x_2, \; y_1 \le Y \le y_2,

and output the result modulo 2302^{30}.

All mathematical formulas are in LaTeX format. HTML tags may be used in this description.

inputFormat

The first line contains an integer mm, the number of operations. Each of the following mm lines represents an operation. An operation starting with 1 indicates a modification operation and is followed by four integers: xx, yy, dd, and ww. An operation starting with 2 indicates a query operation and is followed by four integers: x1x_1, x2x_2, y1y_1, and y2y_2.

outputFormat

For each query operation, output a single line containing the computed sum modulo 2302^{30}.

sample

3
1 1 1 3 5
2 1 3 1 3
2 2 5 2 5
30

5

</p>