| Codeforces Round 1025 (Div. 2) |
|---|
| Finished |
Duelists Mouf and Fouad enter the arena, which is an $$$n \times m$$$ grid!
Fouad's monster starts at cell $$$(a, b)$$$, where rows are numbered $$$1$$$ to $$$n$$$ and columns $$$1$$$ to $$$m$$$.
Mouf and Fouad will keep duelling until the grid consists of only one cell.
In each turn:
Visualization of the phases of the fourth test case. Mouf wants to minimize the number of turns, while Fouad wants to maximize them. How many turns will this epic duel last if both play optimally?
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.
The first and only line of each test case contains four integers $$$n$$$, $$$m$$$, $$$a$$$, and $$$b$$$ ($$$2 \le n, m \le 10^9$$$, $$$1 \le a \le n$$$, $$$1 \le b \le m$$$) — denoting the number of rows, the number of columns, the starting row of the monster, and the starting column of the monster, respectively.
For each test case, output a single integer — the number of turns this epic duel will last if both play optimally.
82 2 1 13 3 2 22 7 1 42 7 2 28 9 4 69 9 5 52 20 2 1122 99 20 70
2 4 4 3 6 8 6 10
In the first test case, one possible duel sequence is as follows:
The duel is completed in $$$2$$$ turns.
In the fourth case, one possible duel sequence is as follows:
In total, the duel is completed in $$$3$$$ turns.
You can refer to the pictures mentioned in the problem statement for illustrations of the fourth test case.
| Name |
|---|


