Ensure that you are logged in and have the required permissions to access the test.
You are walking on a road that is stretched to the infinite distance in both directions. The road can be imagined as a rectangle whose bottom left corner is at (0,0) and the top right corner is at (W,L) on the plane. There are nholes in the plane. Each hole is a rectangle whose upper-left vertex coordinate is (x1,y1) and right-bottom vertex coordinate is (x2,y2). Now, the inner area of every hole is filled with water. You are required to jump through them but only if it is necessary. Therefore, you must always try to avoid the holes in your path. You can only jump above these holes and you will land back to the ground once you cross a hole. The holes can intersect to form larger holes.
You start walking at any point on the bottom side (start line) of the road that is situated at any point in (0...W,0)) and have to reach any point on the top side (finish line) of the road that is situated at any point in (0...W,L). None of the holes intersects with the start or the finish line.
You can jump through one or more intersecting holes but it takes a large amount of time, therefore, you jump through them only if necessary. You must stay inside the road at all times.
Note: If two holes are colliding with each other by the border, then they are considered to be intersecting and you cannot pass these holes without jumping through them.
What is the minimum number of times you must jump in order to reach the endpoint?
Input format
Output Format
For each test case, print a single line containing a single integer denoting the minimum number of times you must jump.
Constraints
1≤n≤1000
1≤W,L≤109
0≤x1,x2≤109
0<y1,y2<109
x1<x2
y2<y1
1≤T≤10
The figure below shows the possible solution.
The red line shows Naruto's Path.
NOTE: There are other ways to fly through polygons.