Alice, a well-known scientist in Berland, has a floor of size N∗M in his research laboratory, with each tile measuring 1X1. If a drop of chemical falls on a tile, it will combine to form a larger drop if there is a drop of chemical solution present in the adjacent tile that shares the common sides or edges.
Note: If a chemical solution falls on the same tile, the size does not change and all indexing are 1 based
You will be given Q queries, each of which can be of two types .
Type 1: Represents coordinates of point on which chemical drop falls
Type 0: Print total number of large drops formed till now.
query of type 1 representing the coordinates of a cell on which chemical drop will fall and for each query of type 0, find the number of connected components in the grid.
Input Format
First line contain 3 integers N,M and Q representing the number of rows, columns and the number of queries.
Next Q lines contain 1 integer which represents the type of query that has been asked.
For query of type 1, there will be 2 more integer x and y which represent the coordinate of cells on which chemical solution is falling on.
for query of type 0, you have to output the number of large drops till now
Output Format
For each query of type 0 output the total number of large drops till now
Constraints
1≤N,M≤103
1≤x≤N
1≤y≤M
1≤Q≤101000
We first marked the cell (2,1) and then cell (2,2) as cell (2,1) and (2,2) share common edges both will connect together to form a single connected component then the cell (3,2) is marked which shares a common edge with cell (2,2) as cell (2,2) & cell (3,2) are connected together they will form a single connected component