Problem: The night after the graduation ceremony graduate students of German University in Cairo (GUC) are playing darts. As there's no real dart board available, the photographs of members of the GUC upper management are being used.

So, n rectangular photos are placed on the wall. They can overlap arbitrary and even coincide. The photos are not necessarily placed horizontally or vertically, they could also be rotated before being pinned to the wall.

The score of one dart throw is simply the number of photos the dart went through.

Fatma has made a throw but her score was not recorded. She only remembers that she did make it into at least one photo.

Assuming that the probability distribution of the throw is equal across the whole wall, what would be the expectation of Fatma's score?

Input

The first line of input contains integer n (1 ≤ n ≤ 500) — the number of photos on the wall. Then follow n lines describing the photos, each containing 8 single-space-separated integers (coordinates of 4 vertices): x1, y1, x2, y2, x3, y3, x4, y4. Each photo is a rectangle with a nonzero area. The coordinates are integers, not exceeding 104 by absolute value. The coordinates of the rectangle are given in either clockwise or counterclockwise order.

Output

Print the expected score of the throw. The answer will be accepted if it has absolute or relative error not exceeding 10 - 6.

Examples

Input

1
0 0 0 2 2 2 2 0


Output

1.0000000000


Input

1
-1 0 0 1 1 0 0 -1


Output

1.0000000000


Input

4
0 0 0 1 3 1 3 0
0 0 0 3 1 3 1 0
3 3 2 3 2 0 3 0
3 3 3 2 0 2 0 3


Output

1.5000000000


Input

2
-1 0 0 1 1 0 0 -1
0 0 1 1 2 0 1 -1


Output

1.1428571429

Solution (in JAVA):

Solution:
import java.awt.geom.*;
import java.util.*;
import java.io.*;

public class Main {

	static Scanner scan = null;

	public static void main(String[] args) {
		if (args.length > 0 && args[0].equals("LOCAL"))	 {
			if (!prepareInput())
				System.exit(0);
		} else 
			scan = new Scanner(System.in);
		Area total = new Area(), tmp;
		int n = scan.nextInt();
		double sum = 0;
		for (int i = 0; i < n; i++) {
			Path2D.Double path = new Path2D.Double();
			double a = scan.nextDouble(), b = scan.nextDouble();
			path.moveTo(a, b);
			for (int j = 0; j < 3; j++) {
				a = scan.nextDouble();
				b = scan.nextDouble();
				path.lineTo(a, b);
			}
			path.closePath();
			tmp = new Area(path);
			total.add(tmp);
			double rhs = calArea(tmp);
//System.out.println(rhs);
			sum += rhs;
		}
			double totalArea = calArea(total);
//System.out.println(totalArea);
		double res = sum / totalArea;
		System.out.println(res);
	}

	private static double calArea(Area area) {
		double ret = 0;
		PathIterator it = area.getPathIterator(null);
		double[] buffer = new double[6], pre = new double[2], first = null;
		for (; !it.isDone(); it.next()) {
			int type = it.currentSegment(buffer);
			if (type == PathIterator.SEG_MOVETO) {
					first = new double[]{buffer[0], buffer[1]};
			} else if (type == PathIterator.SEG_LINETO) {
				ret += pre[0] * buffer[1] - pre[1] * buffer[0];
			} else if (type == PathIterator.SEG_CLOSE) {
				ret += pre[0] * first[1] - pre[1] * first[0]; // shi pre bushi buffer
				first = null; // ! Forgot
			}
			pre[0] = buffer[0];
			pre[1] = buffer[1];
		}
		return ret;
	}

	private static boolean prepareInput() {
		try {
			scan = new Scanner(new File("test.in"));
			return true;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return false;
	}
}