# Team Rocket solution codechef

## Team Rocket solution codechef

Team Rocket is back with a challenge for Ash. They promise to set Pikachu free if he is able to solve the problem

There is a 2d plane which contains zero at every point.

Ash will be given NN operations Where each operation contains three space seperated integers XX YY VV which means

• Add VV coins at position (X,Y)(X,Y)
• And after that print the golden value of the position (X,Y)(X,Y)

Golden value at (X,Y)(X,Y) = (Sum of values at all points (a,b)(a,b) where aXa≥X and bYb≥Y (Sum of all values at (a,b)(a,b) where a<Xa<X and b<Yb<Y)

Help Ash and be let Pikachu be free

### Input:Team Rocket solution codechef

• First line will contain TT, number of testcases. Then input for TT testcases follow.
• First line of each test case is a single integer NN
• Next NN lines contain three space seperated Integers XX YY VV which represent a operation

### Output: Team Rocket solution codechef

• Print output for each operation in a new line

### Constraints Team Rocket solution codechef

• 1T101≤T≤10
• 1N1051≤N≤105
• Sum of all values of N105N≤105
• 5105X5105−5∗105≤X≤5∗105
• 5105Y5105−5∗105≤Y≤5∗105
• 1V1051≤V≤105

### Sample Input: Team Rocket solution codechef

1
6
3 4 2
2 5 6
2 -3 8
1 3 3
-4 1 7
2 2 5


### Sample Output:

2
6
16
11
18
6


### EXPLANATION:

We have one test case and it have 6 queries. we want to answer one by one let us assume you got first five. look at the 6th case 2 2 5

initially value at (2,2) is 0 add 5 to it

Now we have three values 2 5 and 6 which are at (3,4),(2,5),(2,2) whose x-coordinate>=2 and y-coordingate>=2

And we have only one value 7 which is at (-4,1) whose x-coordinate<2 and y-coordinate<2