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.Polygon;
import java.awt.geom.Area;
import java.awt.geom.PathIterator;
import java.awt.geom.Rectangle2D;
import java.io.*;
import java.util.*;

public class Problem_107E {

	BufferedReader in;
	StringTokenizer st;
	PrintWriter out;

	String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(in.readLine());
		return st.nextToken();
	}

	int nextInt() throws Exception {
		return Integer.parseInt(next());
	}

	long nextLong() throws Exception {
		return Long.parseLong(next());
	}

	double nextDouble() throws Exception {
		return Double.parseDouble(next());
	}

	double getArea(double q[], double w[]) {
		return w[0] * q[1] - w[1] * q[0];
	}

	void solve() throws Exception {
		int n = nextInt();
		int x[] = new int[4];
		int y[] = new int[4];

		Area res = new Area();
		double sum = 0;
		for (int i = 0; i < n; i++) {
			double add = 0;
			for (int j = 0; j < 4; j++) {
				x[j] = nextInt();
				y[j] = nextInt();
				if (j != 0)
					add += getArea(new double[] { x[j], y[j] }, new double[] { x[(j + 3) % 4], y[(j + 3) % 4] });
			}

			int j = 0;
			add += getArea(new double[] { x[0], y[0] }, new double[] { x[3], y[3] });

			sum += Math.abs(add);

			Polygon r = new Polygon(x, y, 4);

			res.add(new Area(r));

		}

		double ans = 0;

		PathIterator it = res.getPathIterator(null);

		double first[] = new double[2];
		double curr[] = new double[2];
		double prev[] = new double[2];

		it.currentSegment(first);
		it.next();
		curr = first.clone();

		while (!it.isDone()) {
			prev = curr.clone();
			int type = it.currentSegment(curr);
			if (type == PathIterator.SEG_LINETO)
				ans += getArea(curr, prev);

			if (type == PathIterator.SEG_CLOSE)
				ans += getArea(first, curr);

			if (type == PathIterator.SEG_MOVETO)
				first = curr.clone();
			it.next();
		}

		out.println(Math.abs(sum / ans));
	}

	void run() {
		try {
			Locale.setDefault(Locale.US);
			in = new BufferedReader(new InputStreamReader((System.in)));
			out = new PrintWriter(System.out);

			solve();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	public static void main(String[] args) {
		new Problem_107E().run();

	}

}