Problem: There is a light source on the plane. This source is so small that it can be represented as point. The light source is moving from point to the with speed equal to unit per second. The trajectory of this light source is a straight segment connecting these two points.
There is also a fence on axis represented as segments (so the actual coordinates of endpoints of each segment are and ). The point is in the shade if segment connecting and the current position of the light source intersects or touches with any segment of the fence.
You are given points. For each point calculate total time of this point being in the shade, while the light source is moving from to the .
Input Format: First line contains three space separated integers , and (, ) — corresponding coordinates of the light source.
Second line contains single integer () — number of segments in the fence.
Next lines contain two integers per line: and (, ) — segments in the fence in increasing order. Segments don't intersect or touch each other.
Next line contains single integer () — number of points to check.
Next lines contain two integers per line: and () — points to process.
Output Format: Print lines. The -th line should contain one real number — total time of the -th point being in the shade, while the light source is moving from to the . The answer is considered as correct if its absolute of relative error doesn't exceed .
Note:
- The 1-st point is always in the shade;
- the 2-nd point is in the shade while light source is moving from to ;
- the 3-rd point is in the shade while light source is at point .
- the 4-th point is in the shade while light source is moving from to and at point ;
- the 5-th point is in the shade while light source is moving from to and from to ;