eolymp
bolt
Try our new interface for solving problems
Problems

Revolution

Revolution

During the last parliament elections in Berland two political parties collected the same amount of votes. Now the first party hired you to help them with their plan of a revolution.

During the revolution they want to split the country into two parts. The party is very democratic, so each member has its own separation plan.

The border of Berland can be considered as a convex polygon on the plane. The polygon can have three or more consecutive vertices lay on one line. Each separation plan is represented by the line of the cut.

Your program should calculate the area of the smallest part of the Berland for each separation plan.

Input

The first line contains integer n (3n50 000). Next n lines contain coordinates xi, yi of the Berland border in the clockwise or counterclockwise order. The polygon is non-degenerate. The next line contains integer p (1p50 000). Next p lines contain coordinates x1,j, y1,j, x2,j, y2,j of two distinct points on the separation line. All coordinates are real and do not exceed 10 000 by the absolute value. They are given with no more than 4 significant digits after decimal point.

Output

Print p lines. Each line should contain the area of the smallest part after separating Berland with the corresponding line. Print value with at least 6 digits after decimal point. Absolute or relative error must be less than 10-5.

Example

prb8503.gif

Time limit 2 seconds
Memory limit 128 MiB
Input example #1
5
0 0
0 5
0 10
10 10
10 0
4
0 0 10 10
9 10 10 9
10 -1 12 11
10 10 0 5
Output example #1
50.00000000
0.50000000
0.00000000
25.00000000
Source 2007 Петрозаводск, Saratov for Karelia with love, Январь 28, Задача J