#P9994. Plane Points Operations

    ID: 23138 Type: Default 1000ms 256MiB

Plane Points Operations

Plane Points Operations

Given n distinct points on the plane with coordinates \( (x_i, y_i) \) for \( i=1,2,\dots,n \) and an initial weight \( v_i \) for each point, you need to process m operations. There are two types of operations:

  • Modification Operation: Given an integer \( X \), update the weight \( v_i \) of every point satisfying \( x_i = X \) to \( v_i^2 \).
  • Query Operation: Given an integer \( Y \), compute the sum of weights \( v_i \) for all points satisfying \( y_i = Y \), and output the result modulo \( 10^9+7 \).

All formulas are given in \( \LaTeX \) format. The operations are processed in order.

inputFormat

The first line contains two integers n and m.

The next n lines each contain three integers xi, yi, and vi, representing the coordinate and the initial weight of the i-th point.

The following m lines describe the operations. Each line begins with an integer t representing the type of the operation:

  • If t = 1, it is a modification operation. It is followed by an integer X.
  • If t = 2, it is a query operation. It is followed by an integer Y.

All numbers are space-separated.

outputFormat

For each query operation, output a single line containing the sum of weights of the points with y equal to the given value, modulo \( 10^9+7 \).

sample

3 4
1 2 3
2 2 4
1 3 5
2 2
1 1
2 2
2 3
7

13 25

</p>