Hide

Problem J
Ribbon Road

Christie is an ant that likes to crawl on a closed ribbon (i.e., it forms a polygon with start and end points attached). Her owner, Cindy would place a sugar cube on the ribbon for her to enjoy. Cindy always puts the sugar cube on the exterior side of the ribbon, so Christie wants to crawl on the exterior side in order to expect a sugar cube somewhere down the ribbon road. However, because Christie is so tiny, she usually has trouble finding out if she is crawling on the inside or on the outside of the ribbon. If she is on the inside, then she would need to crawl to the outside carefully.

Fortunately, Christie’s antenna can emit a signal, which is a ray. The rays emitted by Christie travel from her location to some other point $(x,y)$, and the ray may pass through the ribbon. The rays she emits span $[0^\circ , 180^\circ ]$ with the line segment she is current on—the direction parallel to the line segment she stands on pointing forward being $0^\circ $, the span of the ray goes above her, and direction parallel to herself pointing away from her being $180^\circ $. The ribbon does not twist (i.e., the ribbon does not rotate about itself), so that the ribbon is not a Möbius band. Therefore, whether Christie is on the inside or the outside is always the same as she walks along the ribbon.

The ray can be used to determine if Christie is crawling on the inside or the outside of the ribbon. Note that if the ray happens to be parallel to the line segment she stands, then she will not be able to determine if she is inside or outside. Also, if she stands on a vertex of the polygon, then she might not be to determine the answer either. Please help Christie find out if she is on the inside of the ribbon road.

\includegraphics[scale=0.75]{Christie.png}

Input

The first line of input contains a single integer $N$ ($3 \leq N \leq 10^5$), which is the number of vertices in the polygon. The next $N$ lines each contains a pair of integers $(x_ i, y_ i)$, indicating the $i$th vertex of the polygon in order ($1 \leq i \leq N$). The ribbon road is a closed simple polygon so the last vertex is connected back to the first vertex. No three consecutive vertices are colinear. The final line contains four integers $(x_ c, y_ c)$ and $(x,y)$, denoting the location of Christie and a point that Christie’s signal passes through, respectively. Christie always stays on the ribbon in a direction parallel to the ribbon, but the location of $(x, y)$ has no restrictions. If Christie stays on a vertex of the ribbon, then Christie can be parallel to either edge adjacent to that vertex. It is guaranteed that $(x_ c, y_ c) \neq (x,y)$.

All coordinates satisfy $-10^6 \leq x_ i, y_ i, x_ c, y_ c, x, y \leq 10^6$.

Output

Output on a single line inside if Christie is inside, outside if Christie is outside of the ribbon road, or ? if it cannot be determined.

Sample Input 1 Sample Output 1
4
0 0
2 0
2 2
0 2
1 0 1 1
inside
Sample Input 2 Sample Output 2
4
0 0
0 2
2 2
2 0
1 0 -1 0
?
Sample Input 3 Sample Output 3
4
0 0
5 0
5 5
0 5
4 0 1 0
?
Sample Input 4 Sample Output 4
4
0 0
2 0
2 2
0 2
0 0 1 1
inside
Sample Input 5 Sample Output 5
4
0 0
2 0
2 2
0 2
0 0 -1 -1
outside
Sample Input 6 Sample Output 6
4
0 0
1 0
1 1
0 1
0 0 1 -1
?

Please log in to submit a solution to this problem

Log in