eolymp
bolt
Try our new interface for solving problems
Problems

Internal point

Internal point

Given a strictly convex n-polygon and k points.

For each point you need to determine where she is - inside, on the border, or outside.

Input

Number n (3n105). Then given n points - the vertices of the polygon.

Number k (0k105). Then given k points - the queries.

All coordinates are integer, not exceeding 107 by absolute value.

Output

For each query print on a separate line INSIDE, BORDER or OUTSIDE.

Time limit 2 seconds
Memory limit 128 MiB
Input example #1
4
0 0
2 0
2 2
0 2
4
1 1
0 0
0 1
0 3
Output example #1
INSIDE
BORDER
BORDER
OUTSIDE
Author Sergey Kopeliovich