A farm has rows and columns. There is one crop in each of distinct cells. The -th crop is in row and column .
A harvesting machine occupies a consecutive segment of rows in one column. Initially, it occupies only the cell in row and column . That cell has no crop.
You may perform either of these operations:
After an operation, every crop in a cell occupied by the machine is harvested immediately. No part of the machine may leave the farm during an operation.
Find the minimum number of operations needed to harvest every crop.
The input is given in the following format:
For each test case, print the minimum number of operations on one line.
In the first case, two extensions and three moves to the right harvest every crop. In the second case, one extension and two moves to the left are needed.
Each case is given in the following format:
is the number of test cases. Each case gives the farm dimensions, the machine’s initial cell, the number of crops, and the position of each crop.
| 2 | 17 | (). |
| 3 | 23 | (). |
| 4 | 47 | No additional constraints. |