atcoder#ABC168F. [ABC168F] . (Single Dot)
[ABC168F] . (Single Dot)
Score: points
Problem Statement
There is a grass field that stretches infinitely.
In this field, there is a negligibly small cow. Let denote the point that is south and east of the point where the cow stands now. The cow itself is standing at .
There are also north-south lines and east-west lines drawn on the field. The -th north-south line is the segment connecting the points and , and the -th east-west line is the segment connecting the points and .
What is the area of the region the cow can reach when it can move around as long as it does not cross the segments (including the endpoints)? If this area is infinite, print INF
instead.
Constraints
- All values in input are integers between and (inclusive).
- The point does not lie on any of the given segments.
Input
Input is given from Standard Input in the following format:
Output
If the area of the region the cow can reach is infinite, print INF
; otherwise, print an integer representing the area in .
(Under the constraints, it can be proved that the area of the region is always an integer if it is not infinite.)
5 6
1 2 0
0 1 1
0 2 2
-3 4 -1
-2 6 3
1 0 1
0 1 2
2 0 2
-1 -4 5
3 -2 4
1 2 4
13
The area of the region the cow can reach is .
6 1
-3 -1 -2
-3 -1 1
-2 -1 2
1 4 -2
1 4 -1
1 4 1
3 1 4
INF
The area of the region the cow can reach is infinite.