For millenia, people have been interested in approximating π. One famous method is known as Buffon's Needle: drop a bunch of needles of length 1 on a coordiate plane with a vertical line drawn at each integer x coordinate (so there are lines x=0, x=1, x=−1, and so on). Each needle either intersects a vertical line, or lies entirely between two vertical lines. It turns out that, if the needles are dropped randomly, the fraction of needles that intersect a vertical line can be used to approximate π! (The specific assumptions about exactly how the needles are dropped in the experiment are not important for this problem.)
In particular, let x be the fraction of needles that intersect a vertical line. Then
π≈x2.
You are given the positions of N needles (not necessarily random), and it is guaranteed that at least one of them intersects a vertical line. What is the corresponding approximation of π, using the above formula?
The first line of input contains a single integer N (1≤N≤104), the number of needles. N lines follow.
The i-th such line describes the i-th needle. It contains four real numbers: x_i1,y_i1,x_i2,y_i2. This means that the i-th needle has one endpoint at (x_i1,y_i1) in the plane and the other endpoint at (x_i2,y_i2).
All real numbers in the input are given with exactly 6 digits after the decimal point and have absolute value at most 10. Furthermore, it is guaranteed that no x coordinates in the input are within 10−6 of an integer.
Since all the needles are of length 1, for each i it is guaranteed that
∣(x_i1−x_i2)2+(y_i1−y_i2)2−1∣<10−3.
Output a single real number, the approximation of π described above. Your answer is considered correct if its absolute or relative error is at most 10−6.
In the first sample, the first needle intersects a vertical line (x=1), but the second doesn't. So the fraction of needles that intersect vertical lines is 1/2 and the corresponding approximation of π is 4.
In the second sample, both the needles intersect vertical lines (x=1 and x=0), so the fraction of needles that intersect vertical lines is 1 and the corresponding approximation of π is 2.