Please read the new rule regarding the restriction on the use of AI tools. It applies starting from round 972. ×

B. Game with Doors
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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:

  • Alice is in some room from the segment $$$[l, r]$$$;
  • Bob is in some room from the segment $$$[L, R]$$$;
  • Alice and Bob are in different rooms.

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?

Input

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.

Output

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.

Example
Input
4
1 2
3 4
2 5
2 5
3 7
6 7
4 5
2 8
Output
1
3
2
3
Note

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)$$$.