Not a Cakewalk

All submissions for this problem are available.
Chef and Nuttela is busy doing homeworks. Nuttela has faced some math problem and asks Chef to solve it out for him. Nuttela is weak in dealing matrices and so needs Chef help to complete in within a given deadline. Chef asks you to solve it.
You are given a N x M matrix. Then you are given two types of queries  0 and 1.
For the queries of type 0, you need to update the value at index (x, y) to a given value val.
For the queries of type 1, you need to print the sum of the matrix electronic from index (x1, y1) upto (x2, y2).
Can you help to solve the problem?
Input
 The first line contains an integer T denoting the number of test cases. T lines follow.
 The first line of each test case contains two space separated integers N and M, denoting the number of rows and columns respectively.
 N lines follow. Each line contains M space separated integers denoting the elements of the matrix.
 The next line contains a single integer Q denoting the number of queries. Q lines follow.
 The first integer of each line denotes the type of the query  0 or 1.
 For the queries of type 0 the line contains 3 more space separated integers x1 , y1 and val denoting you need to change the value of A[x1][y1] to val.
 For the queries of type 1 the line contains 4 more space separated integers x1 , y1, x2 and y2 denoting you need to print the sum of the values in the bounds of (x1, y1) to (x2, y2).
Output
For every query of type c = 1, output the answer to the query in a new line.
Constraints
 1 ≤ T ≤ 10
 1 ≤ N , M ≤ 500
 0 ≤ A[i][j] ≤ 10^{9}
 0 ≤ Q ≤ 10^{5}
 0 ≤ c ≤ 1
 1 ≤ x1, x2 ≤ N
 1 ≤ y1, y2 ≤ M
 0 ≤ val ≤ 10^{9}
Example Input
1 4 4 5 3 8 6 9 2 4 7 4 5 1 6 7 3 2 1 3 1 1 2 4 4 0 3 2 1 1 1 2 4 4
Example Output
12 6
Author:  horsbug98 
Editorial  https://discuss.codechef.com/problems/HTST8 
Tags  easy, encoding, enma2019, horsbug98, horsbug98, matrix 
Date Added:  23032019 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions