There are $$$100$$$ rooms arranged in a row and $$$99$$$ doors between them; the $$$i$$$-th door connects rooms $$$i$$$ and $$$i+1$$$. Each door can be either locked or unlocked. Initially, all doors are unlocked.
We say that room $$$x$$$ is reachable from room $$$y$$$ if all doors between them are unlocked.
You know that:
However, you don't know the exact rooms they are in.
You don't want Alice and Bob to be able to reach each other, so you are going to lock some doors to prevent that. What's the smallest number of doors you have to lock so that Alice and Bob cannot meet, regardless of their starting positions inside the given segments?
The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases.
The first line of each test case contains two integers $$$l$$$ and $$$r$$$ ($$$1 \le l < r \le 100$$$) — the bounds of the segment of rooms where Alice is located.
The second line of each test case contains two integers $$$L$$$ and $$$R$$$ ($$$1 \le L < R \le 100$$$) — the bounds of the segment of rooms where Bob is located.
For each test case, print a single integer — the smallest number of doors you have to lock so that Alice and Bob cannot meet, regardless of their starting positions inside the given segments.
41 23 42 52 53 76 74 52 8
1 3 2 3
In the first test case, it is sufficient to lock the door between rooms $$$2$$$ and $$$3$$$.
In the second test case, the following doors have to be locked: $$$(2,3)$$$, $$$(3,4)$$$, $$$(4,5)$$$.
In the third test case, the following doors have to be locked: $$$(5, 6)$$$ and $$$(6,7)$$$.
Name |
---|