


For example: Consider an empty matrix of size 'N'*'N' where 'N' = 3.
[[ 'NULL', 'NULL', 'NULL']
[ 'NULL', 'NULL', 'NULL']
[ 'NULL', 'NULL', 'NULL']]
Suppose the value of 'K' is 2, which means we have to perform 2 tasks.
Task 1: (0, 0)
Matrix after placing 0 in each cell of 0th row and 0th column:
[[0, 0, 0]
[ 0, 'NULL', 'NULL']
[ 0, 'NULL', 'NULL']]
The number of empty cells now: 4
Task 2: (1,0)
Matrix after placing 0 in each cell of 1st row and 0th column:
[[0, 0, 0]
[ 0, 0, 0]
[ 0, 'NULL', 'NULL']]
The number of empty cells now: 2
Return the array [4,2]
1. We call a cell empty only if it does not contain any value.
2. Indexing is 0-based.
The first line of input contains a single integer T, representing the number of test cases or queries to be run.
Then the T test cases follow.
The first line of every test case contains two space-separated integers 'N' and 'K', where 'N' is the number of rows, and the columns of the given matrix and 'K' is the number of tasks.
Next 'K' lines of each test case contain two space-separated integers 'I' and 'J'.
For each test case, print a line that contains a vector/array containing the number of empty cells in the matrix after each task.
You are not required to print anything it has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= 'N' <= 10^5
0 <= 'K' <= 10^5
0 <= 'I','J' < 'N'
Time limit: 1 second
We will create a matrix of size 'N' * 'N' and initialize all of its elements with a number say -1. Now for every task ('I', 'J'), we will be replacing -1 with 0 for every cell of the ith row and jth column.
Now we will simply count the number of -1 in the matrix using two loops, and we will print it.
Algorithm:
Suppose we have a task ('I', 'J'). Now we will update ith row and jth column of the matrix by 0. What can we conclude from this? We can say that the ith row and jth column will not contribute any empty cells. So we can just consider a matrix not having ith row and jth column. This means our number of rows has been reduced by one and the number of columns has also been reduced by 1.
Algorithm: