After counting so many stars in the sky in his childhood, Isaac, now an astronomer and a mathematician uses a big astronomical telescope and lets his image processing program count stars. The hardest part of the program is to judge if shining object in the sky is really a star. As a mathematician, the only way he knows is to apply a mathematical definition of stars.

The mathematical definition of a star shape is as follows: A planar shape F is star-shaped if and only if there is a point C ∈ F such that, for any point P ∈ F, the line segment CP is contained in F. Such a point C is called a center of F. To get accustomed to the definition let’s see some examples below.




The first two are what you would normally call stars. According to the above definition, however, all shapes in the first row are star-shaped. The two in the second row are not. For each star shape, a center is indicated with a dot. Note that a star shape in general has infinitely many centers. Fore Example, for the third quadrangular shape, all points in it are centers.

Your job is to write a program that tells whether a given polygonal shape is star-shaped or not.

Input

The input is a sequence of datasets followed by a line containing a single zero. Each dataset specifies a polygon, and is formatted as follows.

n x1y1x2y2

xnyn

The first line is the number of vertices, n, which satisfies 4 ≤ n ≤ 50. Subsequent n lines are the x- and y-coordinates of the n vertices. They are integers and satisfy 0 ≤ xi ≤ 10000 and 0 ≤ yi ≤ 10000 (i = 1, …, n). Line segments (xiyi)–(xi + 1yi + 1) (i = 1, …, n − 1) and the line segment (xnyn)–(x1y1) form the border of the polygon in the counterclockwise order. That is, these line segments see the inside of the polygon in the left of their directions.

You may assume that the polygon is simple, that is, its border never crosses or touches itself. You may assume assume that no three edges of the polygon meet at a single point even when they are infinitely extended.

Output

For each dataset, output “​​1​​​” if the polygon is star-shaped and “​​0​​” otherwise. Each number must be in a separate line and the line should not contain any other characters.

Sample Input

6 66 13 96 61 76 98 13 94 4 0 45 68 8 27 21 55 14 93 12 56 95 15 48 38 46 51 65 64 31 0

Sample Output

10


模板题,wa一直找不到错误,最后只好一块一块的将自己的代码替换成别人的,终于让我发现在运算符重载的时候写错一个*号,由于我的结构体初始化允许只传进一个参数,无限wa,wa到怀疑人生。现在发现学的高数还是有用的,特别是在遇到几何题目的时候。

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
const int mx = 60;
using namespace std;
typedef struct poi{
double x;
double y;
poi(double a = 0, double b = 0){
x = a; y = b;
}

poi operator + (const poi a) const{
return poi(x+a.x, y+a.y);
}

poi operator - (const poi a) const{
return poi(x-a.x, y-a.y);
}

double operator * (const poi a) const{
return (x*a.x + y*a.y);
}

poi operator * (const double a) const{
return poi(x*a , y*a); //这里重载错了直接爆炸一直wa,逗号写成加号
}

double operator ^(const poi a) const{
return(x*a.y - y*a.x);
}

}vec;
poi P[mx], S[mx*10], T[mx*10];
int n;

int dbcmp(double a){
return fabs(a)<(1e-6)?0:(a>0?1:-1);
}

poi getline(poi p, vec v, poi q, vec w){
vec u = p - q;
double t = (w^u)/(v^w);
return p+v*t;
}

bool judge(){
for(int i = 0; i < n; i++){
S[i] = P[i];
}
int num1 = n, add;

for(int i = 0; i < n; i++){
add = 0;
for(int j = 0; j < num1; j++){
int ans1 = dbcmp((P[(i+1)%n]-P[i]) ^ (S[j]-P[i]));
int ans2 = dbcmp((P[(i+1)%n]-P[i]) ^ (S[(j+1)%num1]-P[i]));

if(ans1 >= 0)
T[add++] = S[j];
if(ans1 * ans2 < 0)
T[add++] = getline(P[i], (P[(i+1)%n]-P[i]), S[j], (S[(j+1)%num1]-S[j]));
}

for(int k = 0; k < add; k++){
S[k] = T[k];
}
num1 = add;
}

return num1 != 0;
}

int main(){
while(scanf("%d",&n) && n){

for(int i = 0; i < n; i++){
scanf("%lf%lf", &P[i].x, &P[i].y);
}

if(judge()) puts("1");
else puts("0");
}

return 0;
}