124. Broken line¶
time limit per test: 0.25 sec / memory limit per test: 4096 KB
There is a closed broken line on a plane with sides parallel to coordinate axes, without self-crossings and self-contacts. The broken line consists of K segments. You have to determine, whether a given point with coordinates (X0,Y0) is inside this closed broken line, outside or belongs to the broken line.
Input
The first line contains integer K (4 <= K <= 10000) - the number of broken line segments. Each of the following N lines contains coordinates of the beginning and end points of the segments (4 integer \(x_{i1},y_{i1},x_{i2},y_{i2}\); all numbers in a range from -10000 up to 10000 inclusive). Number separate by a space. The segments are given in random order. Last line contains 2 integers \(X_0\) and :”math:Y_0 - the coordinates of the given point delimited by a space. (Numbers math:X_0, math:Y_0 in a range from -10000 up to 10000 inclusive).
Output
The first line should contain:
INSIDE - if the point is inside closed broken line,
OUTSIDE - if the point is outside,
BORDER - if the point belongs to broken line.
Example(s)
| Sample Input | Sample Output |
4
0 0 0 3
3 3 3 0
0 3 3 3
3 0 0 0
2 2
|
INSIDE
|