Problem: Prof. Bocchan is a mathematician and a sculptor. He likes to create sculptures with mathematics.

His style to make sculptures is very unique. He uses two identical prisms. Crossing them at right angles, he makes a polyhedron that is their intersection as a new work. Since he finishes it up with painting, he needs to know the surface area of the polyhedron for estimating the amount of pigment needed.

For example, let us consider the two identical prisms in Figure 1. The definition of their cross section is given in Figure 2. The prisms are put at right angles with each other and their intersection is the polyhedron depicted in Figure 3. An approximate value of its surface area is 194.8255.

<image>

Figure 1: Two identical prisms at right angles

Given the shape of the cross section of the two identical prisms, your job is to calculate the surface area of his sculpture.



Input

The input consists of multiple datasets, followed by a single line containing only a zero. The first line of each dataset contains an integer n indicating the number of the following lines, each of which contains two integers ai and bi (i = 1, ... , n).

<image>

Figure 2: Outline of the cross section

<image>

Figure 3: The intersection

A closed path formed by the given points (a1, b1), (a2, b2 ), ... , (an, bn), (an+1, bn+1)(= (a1, b1)) indicates the outline of the cross section of the prisms. The closed path is simple, that is, it does not cross nor touch itself. The right-hand side of the line segment from (ai, bi) to (ai+1 , bi+1 ) is the inside of the section.

You may assume that 3 ≤ n ≤ 4, 0 ≤ ai ≤ 10 and 0 ≤ bi ≤ 10 (i = 1, ... , n).

One of the prisms is put along the x-axis so that the outline of its cross section at x = ζ is indicated by points (xi, yi, zi ) = (ζ, ai, bi) (0 ≤ ζ ≤ 10, i = 1, ... , n). The other prism is put along the y-axis so that its cross section at y = η is indicated by points (xi, yi, zi) = (ai, η, bi) (0 ≤ η ≤ 10, i = 1, ... , n).

Output

The output should consist of a series of lines each containing a single decimal fraction. Each number should indicate an approximate value of the surface area of the polyhedron defined by the corresponding dataset. The value may contain an error less than or equal to 0.0001. You may print any number of digits below the decimal point.

Example

Input

4
5 0
0 10
7 5
10 5
4
7 5
10 5
5 0
0 10
4
0 10
10 10
10 0
0 0
3
0 0
0 10
10 0
4
0 10
10 5
0 0
9 5
4
5 0
0 10
5 5
10 10
4
0 5
5 10
10 5
5 0
4
7 1
4 1
0 1
9 5
0


Output

194.8255
194.8255
600.0000
341.4214
42.9519
182.5141
282.8427
149.2470

Solution (in CPP):

Solution:
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

typedef double Real;

const Real eps=1e-8;

int N;
int xs[5],ys[5];

Real getLen(Real h){
	vector<Real> vals;
	for(int i=0;i<N;i++){
		int x1=xs[i],y1=ys[i];
		int x2=xs[i+1],y2=ys[i+1];
		if(y1==y2) continue;
		if(y1>y2){
			swap(y1,y2);
			swap(x1,x2);
		}
		if(h<y1||y2<h) continue;
		Real r=(Real)(h-y1)/(y2-y1);
		Real x=x1+(Real)(x2-x1)*r;
		vals.push_back(x);
	}
	sort(vals.begin(),vals.end());
	Real res=0;
	for(int i=0;i+1<vals.size();i+=2){
		res+=vals[i+1]-vals[i];
	}
//	printf("h=%f,res=%f\n",h,res);
	return res;
}

vector<Real> hs;

Real solve(){
	Real ans=0;
	for(int i=0;i<N;i++){
		hs.push_back(ys[i]+eps);
		hs.push_back(ys[i]-eps);
	}
	sort(hs.begin(),hs.end());
	vector<int> same_y;
	for(int i=0;i<N;i++){
		if(ys[i]==ys[i+1]){
			same_y.push_back(ys[i]);
			continue;
/*			Real len1=getLen(ys[i]-eps);
			Real len2=getLen(ys[i]+eps);
//			printf("+=(%f,%f)->%f\n",len1,len2,abs(len1*len1-len2*len2));
			ans+=abs(len1*len1-len2*len2);*/
		}else{
			int x1=xs[i],y1=ys[i];
			int x2=xs[i+1],y2=ys[i+1];
			if(y1>y2){
				swap(y1,y2);
				swap(x1,x2);
			}
			Real h=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
			for(int j=0;j+1<hs.size();j++){
				Real lo=hs[j],hi=hs[j+1];
				if(lo<y1||y2<hi) continue;
				Real len1=getLen(lo);
				Real len2=getLen(hi);
				Real cur_h=h*(hi-lo)/(y2-y1);
				ans+=(len1+len2)*cur_h;
			}
		}
	}
	sort(same_y.begin(),same_y.end());
	same_y.erase(unique(same_y.begin(),same_y.end()),same_y.end());
	for(int i=0;i<same_y.size();i++){
		int y=same_y[i];
		Real len1=getLen(y-eps);
		Real len2=getLen(y+eps);
		ans+=abs(len1*len1-len2*len2);
	}
	return ans;
}

int main(){
	while(true){
		scanf("%d",&N);
		if(N==0) break;
		for(int i=0;i<N;i++) scanf("%d%d",xs+i,ys+i);
		xs[N]=xs[0],ys[N]=ys[0];
		Real ans=solve();
		printf("%f\n",ans);
	}
	return 0;
}