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
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;
int X[2][5];
int Y[2][5];
int L[20];
int R[20];
double EPS=1e-9;
int ABS(int a){return max(a,-a);}
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<20;i++){
			L[i]=R[i]=0;
		}
		for(int i=0;i<a;i++)scanf("%d%d",&X[0][i],&Y[0][i]);
		X[0][a]=X[0][0];
		Y[0][a]=Y[0][0];
		for(int i=0;i<a-1;i++){
			if(Y[0][i]==Y[0][i+1]&&Y[0][i+1]==Y[0][i+2]){
				for(int j=i+1;j<a;j++){
					X[0][j]=X[0][j+1];
					Y[0][j]=Y[0][j+1];
				}
				a--;break;
			}
		}
		int b=a;
		for(int i=0;i<=a;i++){
			X[1][i]=X[0][i];Y[1][i]=Y[0][i];
		}
		double ret=0;
		for(int i=0;i<a;i++){
			if(Y[0][i]==Y[0][i+1]){
				L[Y[0][i]]=ABS(X[0][i]-X[0][i+1]);
			}else{
				double ks=sqrt((Y[0][i]-Y[0][i+1])*(Y[0][i]-Y[0][i+1])+(X[0][i]-X[0][i+1])*(X[0][i]-X[0][i+1]))/ABS(Y[0][i]-Y[0][i+1]);
				double tmp=0;
				for(int j=min(Y[0][i],Y[0][i+1]);j<max(Y[0][i],Y[0][i+1]);j++){
					vector<double>now;
					for(int k=0;k<b;k++){
						if(min(Y[1][k],Y[1][k+1])<=j&&j<max(Y[1][k],Y[1][k+1])){
							now.push_back((double)X[1][k]+(double)(X[1][k+1]-X[1][k])*(j+0.5-Y[1][k])/(Y[1][k+1]-Y[1][k]));
						}
					}
					std::sort(now.begin(),now.end());
					for(int k=0;k<now.size();k++){
						if(k%2)tmp+=now[k];
						else tmp-=now[k];
					}
				}
			//	tmp/=2;
				tmp*=ks;
				ret+=tmp;
			}
		}
for(int i=0;i<b;i++){
			if(Y[1][i]==Y[1][i+1]){
				R[Y[1][i]]=ABS(X[1][i]-X[1][i+1]);
			}else{
				double ks=sqrt((Y[1][i]-Y[1][i+1])*(Y[1][i]-Y[1][i+1])+(X[1][i]-X[1][i+1])*(X[1][i]-X[1][i+1]))/ABS(Y[1][i]-Y[1][i+1]);
				double tmp=0;
				for(int j=min(Y[1][i],Y[1][i+1]);j<max(Y[1][i],Y[1][i+1]);j++){
					vector<double>now;
					for(int k=0;k<a;k++){
						if(min(Y[0][k],Y[0][k+1])<=j&&j<max(Y[0][k],Y[0][k+1])){
							now.push_back((double)X[0][k]+(double)(X[0][k+1]-X[0][k])*(j+0.5-Y[0][k])/(Y[0][k+1]-Y[0][k]));
						}
					}
					std::sort(now.begin(),now.end());
					for(int k=0;k<now.size();k++){
						if(k%2)tmp+=now[k];
						else tmp-=now[k];
					}
				}
			//	tmp/=2;
				tmp*=ks;
				ret+=tmp;
			}
		}
		for(int i=0;i<=10;i++){
			vector<double>v;
			for(int j=0;j<a;j++){
				if(min(Y[0][j],Y[0][j+1])<=i&&i<=max(Y[0][j],Y[0][j+1])){
					if(Y[0][j]==Y[0][j+1]){
						v.push_back(X[0][j]);
						v.push_back(X[0][j+1]);
					}else v.push_back((double)X[0][j]+(double)(X[0][j+1]-X[0][j])*(i-Y[0][j])/(Y[0][j+1]-Y[0][j]));
				}
			}
			std::sort(v.begin(),v.end());
			vector<double>V;
			for(int j=0;j<v.size();j++){
				if(j==0||v[j]-v[j-1]>EPS)V.push_back(v[j]);
			}
			double t1=0;
			if(V.size()==4){
				t1=V[3]+V[1]-V[2]-V[0];
			}else if(V.size()>1){
				t1=V[V.size()-1]-V[0];
			}
			vector<double>w;
			for(int j=0;j<b;j++){
				if(min(Y[1][j],Y[1][j+1])<=i&&i<=max(Y[1][j],Y[1][j+1])){
					if(Y[1][j]==Y[1][j+1]){
						w.push_back(X[1][j]);
						w.push_back(X[1][j+1]);
					}else w.push_back((double)X[1][j]+(double)(X[1][j+1]-X[1][j])*(i-Y[1][j])/(Y[1][j+1]-Y[1][j]));
				}
			}
			std::sort(w.begin(),w.end());
			vector<double>W;
			for(int j=0;j<w.size();j++){
				if(j==0||w[j]-w[j-1]>EPS)W.push_back(w[j]);
			}
			double t2=0;
			if(W.size()==4){
				t2=W[3]+W[1]-W[2]-W[0];
			}else if(W.size()>1){
				t2=W[W.size()-1]-W[0];
			}
	//		printf("%f %f\n",t1,t2);
			ret+=L[i]*t2;
			ret+=R[i]*t1;
			ret-=L[i]*R[i];
		}
		printf("%.12f\n",ret);
	}
}