How I Mathematician Wonder What You Are!

Time limit1sMemory limit128 MB

Problem

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

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 \in F$ such that, for every point $P \in F$, the line segment $CP$ is contained in $F$. Such a point $C$ is called a center of $F$.

By this definition, not only the stars you would normally draw but many other shapes are star-shaped as well. A star-shaped region in general has infinitely many centers; for a convex polygon, for instance, every point of the polygon is a center.

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

Input

The input is a sequence of datasets, followed by a line containing a single zero. Each dataset specifies a polygon in the following format:

n
x1 y1
x2 y2
...
xn yn

The first line is the number of vertices $n$, which satisfies $4 \le n \le 50$. The next $n$ lines give the $x$- and $y$-coordinates of the $n$ vertices; they are integers and satisfy $0 \le x_i \le 10000$ and $0 \le y_i \le 10000$ ($i = 1, \ldots, n$). The line segments $(x_i, y_i)$–$(x_{i+1}, y_{i+1})$ (for $i = 1, \ldots, n-1$) and the line segment $(x_n, y_n)$–$(x_1, y_1)$ form the border of the polygon in counterclockwise order; that is, each segment has the inside of the polygon on the left of its direction.

You may assume that the polygon is simple, that is, its border never crosses or touches itself. You may also 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 answer must be on its own line, and the line must contain no other characters.