Little-L has a box divided into an $$$n \times m$$$ grid of cells.
Initially, all cells are empty. You can perform several operations, each of which can be one of the following two types:
For example, in a $$$5 \times 5$$$ box, choosing cell $$$(3,4)$$$ for either the first or the second operation would yield the following results:
The left figure shows the first operation, and the right figure shows the second operation. Little-L wants to know: what is the minimum number of operations needed to fill all cells in the box with balls?
Note: You can perform an operation on a cell that already contains a ball.
Each test file contains multiple test cases. The first line contains the number of test cases $$$T$$$ ($$$1 \leq T \leq 10^4$$$). The description of the test cases follows.
The first line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 10^3$$$), representing the number of rows and columns of the box.
In each test file, it is guaranteed that the sum of $$$n \times m$$$ across all test cases does not exceed $$$10^6$$$.
For each test case:
The first line should contain a single integer $$$p$$$ ($$$1 \leq p \leq n \times m$$$), representing the minimum number of operations.
The next $$$p$$$ lines each contain three integers $$$op, x, y$$$ ($$$op \in \{1,2\}, 1 \leq x \leq n, 1 \leq y \leq m$$$), indicating one operation. If $$$op=1$$$, perform the first type of operation at cell $$$(x,y)$$$; if $$$op=2$$$, perform the second type of operation at cell $$$(x,y)$$$.
23 42 2
3 2 2 2 2 2 3 1 2 4 2 1 1 1 1 2 2