DS Team Selection

아직 제출이 없습니다시간 제한18초메모리 제한1024 MB

문제

The 34th International Olympiad in Data Structures will take place soon! In order to qualify, you need to pass the team selection contest in your country. As a member of the Cat team, you have to solve this problem in the Cat Team Selection contest.

There are infinitely many points with integer coordinates on an infinite plane, each of which can be represented as (x,y)(x, y). Initially, the weights of all points are 00. You need to perform qq operations, each of which takes the form:

  • 1 xx yy dd ww: For all points (X,Y)(X,Y) that satisfy Xx\<d|X-x|\<d and Yy\<d|Y-y|\<d, increase their point weights by w(dmax(Xx,Yy))w \cdot (d - \max(|X-x|,|Y-y|)).
  • 2 x_1x\_1 x_2x\_2 y_1y\_1 y_2y\_2: Print the sum of the weights of points (x,y)(x,y) that satisfy x_1xx_2x\_1 \le x \le x\_2 and y_1yy_2y\_1 \le y \le y\_2. Since the sum can be large, output it modulo 2302^{30}.

입력

The first line contains a single integer mm (1m1051 \le m \le 10^5), indicating the number of the operations.

The next mm lines contains several integers in one of the following forms:

  • 1 xx yy dd ww (1x,y,d,w1081 \le x,y,d,w \le 10^8)
  • 2 x_1x\_1 x_2x\_2 y_1y\_1 y_2y\_2 (1x_1x_21081 \le x\_1 \le x\_2 \le 10^8, 1y_1y_21081 \le y\_1 \le y\_2 \le 10^8)

출력

For each operation of type 2, print a single line containing an integer: the desired sum of the weights modulo 2302^{30}.