The use of the central road in Utopia’s capital has increased by a great value in recent years. So, the Ministry of Transport wants to expand its width while keeping the length constant. However, there are important buildings on both sides of the highway and before requesting the Ministry of Habitation to move any of those, they want to find out the maximum width the road can have without intersecting the buildings.
Formally, there are buildings of convex polygonal shape and a line segment representing the road. Initially, the width of the road is considered to be zero. The Ministry of Transport wants to find out the maximum width the road can have such that it does not go through any of the buildings i.e. no building should have a positive area on the road. After expansion, the road will be of a rectangular shape with two sides parallel to .
In the example image above, there are 8 buildings at various locations. The road is depicted by the line segment . The expanded road is denoted via the green dotted rectangle. Note that, no building intersects the expanded road.
As the intern programmer at the Ministry of Transport, you have to find out the maximum width the central road can have.
The first line contains a single positive integer denoting the number of test cases. Description of test cases follows. For each test case —
The first line contains four space-separated real numbers denoting the road endpoints and , respectively.
The following line contains a positive integer denoting the number of convex polygons i.e. buildings.
lines follow, each describing a polygon. Each of these lines contain a positive integer denoting the number of vertices in the current polygon followed by real numbers , denoting the coordinates of the vertices of the polygon.
It is guaranteed that —
The number of vertices of a polygon is inclusively between 3 and 10.
For any coordinate in the input, and both have exactly two digits after the decimal point.
In the input, no polygon touches or intersects with the given line segment, i.e. no part of the line is inside or on any polygon.
The polygons are convex, have a positive area, and do not intersect among themselves.
It is guaranteed that the maximum expanded width of the road is finite.
Output a real number that denotes the maximum width the road can be expanded to. Your output will be considered correct if the absolute or relative error is less than .
1 0.00 0.00 10.00 0.00 2 5 2.00 2.00 4.00 1.00 7.00 2.00 5.00 5.00 2.00 4.00 4 3.00 -4.00 6.00 -4.00 7.00 -1.50 3.00 -1.50
Sample I/O Explanation
A convex polygon is a simple polygon where each of the interior angles is less than or equal to 180 degrees.
A simple polygon is a polygon that does not intersect itself and has no holes.
A polygon is a plane figure that is described by a finite number of straight-line segments connected to form a closed polygonal chain (or polygonal circuit).
A polygonal chain is a connected series of line segments.