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.Area;
import java.awt.geom.Path2D;
import java.awt.geom.PathIterator;
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.*;

public class Main {
	

	void println(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void run() throws Exception {
	    InputReader scan = new InputReader(System.in);
		int n = scan.nextInt();
		Area first = new Area();
		double area = 0;
		P[] all = new P[n * 4];
		int cur = 0;
		for (int i = 0; i < n; i++) {
			P[] ps = new P[4];
			for (int j = 0; j < 4; j++) {
				ps[j] = new P(scan.nextDouble(), scan.nextDouble());
				all[cur++] = ps[j];
			}
			ps = G.convexHull(ps);
			area += G.area(ps);
			first.add(makeArea(ps));
		}
		P[] h = G.convexHull(all);
		Area hull = makeArea(h);
		double total = evalArea(hull);
		hull.exclusiveOr(first);
		total -= evalArea(hull);
		System.out.println(area / total);
	}

	Area makeArea(P[] ps) {
		Path2D.Double p = new Path2D.Double();
		p.moveTo(ps[0].x, ps[0].y);
		for (int i = 1; i < ps.length; i++)
			p.lineTo(ps[i].x, ps[i].y);
		p.closePath();
		return new Area(p);
	}

	double evalArea(Area a) {
		double ret = 0;
		PathIterator iter = a.getPathIterator(null);
		List<P> ps = new ArrayList<P>();
		double[] buffer = new double[6];
		while (!iter.isDone()) {
			switch (iter.currentSegment(buffer)) {
			case PathIterator.SEG_MOVETO:
			case PathIterator.SEG_LINETO:
				ps.add(new P(buffer[0], buffer[1]));
				break;
			case PathIterator.SEG_CLOSE:
				ret += G.area(ps.toArray(new P[0]));
				ps.clear();
				break;
			}
			iter.next();
		}
		return ret;
	}

	public static void main(String[] args)throws Exception {
		// TODO Auto-generated method stub
		new Main().run();
	}
	
	static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;
        
        public InputReader(InputStream stream) {
          reader = new BufferedReader(new InputStreamReader(stream));
          tokenizer = null;
        }
        
        public String next()throws Exception {
          while (tokenizer == null || !tokenizer.hasMoreTokens())
            tokenizer = new StringTokenizer(reader.readLine());
          return tokenizer.nextToken();
        }
        
        public String nextLine()throws Exception {
          String line = null;
          tokenizer = null;
          line =  reader.readLine();
          return line;
        }
        
        public int nextInt()throws Exception {
          return Integer.parseInt(next());
        }
        
        public double nextDouble() throws Exception{
          return Double.parseDouble(next());
        }
        
        public long nextLong()throws Exception {
          return Long.parseLong(next());
        }
    
  }
	
}

class P implements Comparable<P> {
	double x, y;

	P() {
	}

	P(double x, double y) {
		this.x = x;
		this.y = y;
	}

	P add(P p) {
		return new P(x + p.x, y + p.y);
	}

	P sub(P p) {
		return new P(x - p.x, y - p.y);
	}

	P mult(double f) {
		return new P(x * f, y * f);
	}

	P div(double f) {
		return new P(x / f, y / f);
	}

	double det(P p) {
		return x * p.y - y * p.x;
	}

	double dot(P p) {
		return x * p.x + y * p.y;
	}

	@Override
	public int compareTo(P o) {
		// TODO Auto-generated method stub
		int c = G.sign(x - o.x);
		if (c != 0)
			return c;
		return G.sign(y - o.y);
	}

	@Override
	public String toString() {
		return "(" + x + "," + y + ")";
	}
}

class G {
	static final double EPS = 1e-8;

	static int sign(double s) {
		return s < -EPS ? -1 : s > EPS ? 1 : 0;
	}

	static double cross(P p1, P p2, P p3) {
		return p2.sub(p1).det(p3.sub(p1));
	}

	static int crossOp(P p1, P p2, P p3) {
		return sign(cross(p1, p2, p3));
	}

	static P isSS(P p1, P p2, P q1, P q2) {
		double a1 = cross(q1, q2, p1), a2 = -cross(q1, q2, p2);
		if (Math.abs(a1 + a2) <= EPS)
			return null;
		return p1.mult(a2).add(p2.mult(a1)).div(a1 + a2);
	}

	static double area(P[] ps) {
		double ret = 0;
		for (int i = 0; i < ps.length; i++)
			ret += ps[i].det(ps[(i + 1) % ps.length]);
		return Math.abs(ret / 2);
	}

	static P[] convexCut(P[] ps, P q1, P q2) {
		List<P> qs = new ArrayList<P>();
		for (int i = 0; i < ps.length; i++) {
			P p1 = ps[i], p2 = ps[(i + 1) % ps.length];
			int d1 = crossOp(q1, q2, p1), d2 = crossOp(q1, q2, p2);
			if (d1 >= 0)
				qs.add(p1);
			if (d1 * d2 < 0)
				qs.add(isSS(p1, p2, q1, q2));
		}
		return qs.toArray(new P[0]);
	}

	static P[] convexHull(P[] ps) {
		if (ps.length <= 1)
			return ps;
		Arrays.sort(ps);
		int n = ps.length;
		P[] qs = new P[n * 2];
		int k = 0;
		for (int i = 0; i < n; qs[k++] = ps[i++])
			while (k > 1 && crossOp(qs[k - 2], qs[k - 1], ps[i]) <= 0)
				--k;
		for (int i = n - 2, t = k; i >= 0; qs[k++] = ps[i--])
			while (k > t && crossOp(qs[k - 2], qs[k - 1], ps[i]) <= 0)
				--k;
		P[] res = new P[k - 1];
		System.arraycopy(qs, 0, res, 0, k - 1);
		return res;
	}
}