Input: N = 3, queries[][] = {{1, 2, 0, 2} , {2, 0, 0, 2, 2}, {1, 0, 0, 1}, {2, 0, 0, 2, 0} }
Output: [2, 3]
Explanation:

The first query is to update the value of cell (2, 0) to 2. The second query is to take the sum of the submatrix (0, 0) to (2, 2) which is equal to 2. The third query is to update the value of cell (0, 0) to 1. The fourth query is to take the sum of the submatrix (0, 0) to submatrix (2, 0) which is equal to 3.
Input: N = 3, queries = { { 1, 0, 2, 2 }, { 1, 0, 0, 1 }, { 2, 0, 0, 2, 2 }, { 1, 0, 1, 1 }, { 2, 0, 0, 0, 2 } }
Output: [3, 4]
Explanation: The first query is to update the value of cell (0, 2) to 2. The second query is to update the value of cell (0, 0) to 1. The third query is to take the sum of the submatrix (0, 0) to (2, 2), which is equal to 3. The fourth query is to update the value of cell (0, 1) to 1 and the fifth query is to take the sum of the submatrix (0, 0) to submatrix (0, 2) which is equal to 4.
Since we need to answer the update and sum queries in log(N) time, we can solve them using Fenwick tree on 2D matrix. We can maintain a 2D Binary Indexed Tree to store the partial sums of the matrices.
Point Update: Whenever we have to update a cell (x, y), we start with the current row x and update all the cells in row x which stores the partial sum of cell (x, y) by changing y to y + (y & -y). Then, we move to the next row which stores the partial sum of cell (x, y) by changing x to x + (x & -x).
Range Sum: Whenever we have to find the range sum of submatrix (x1, y1) to (x2, y2) then we can calculate it using the formula: prefixSum(x2, y2) - prefixSum(x2, y1) - prefixSum(x1, y2) + prefixSum(x2, y2)