Formula Flatland
Your job only consists of selecting some road segments which form a circle but are connected by as few crossings as possible. Note that even though all roads in Flatland are bidirectional, they can only be used in one direction during the race for safety reasons.
Input
The input consists of:
-
One line with two integers $n$ and $m$ ($4\leq n \leq 10^5\text{ and }5\leq m\leq 3\cdot 10^5$), the number of crossings and the number of road segments in Flatland.
-
$n$ lines, each with two integers $x$ and $y$ ($0\leq x,y\leq 10^9$), the $i$th line describes the position of the $i$th crossing on a map of Flatland. No two crossings are at the same position.
-
$m$ lines, each with two integers $a$ and $b$ ($1\leq a,b\leq n\text{ and }a\neq b$), describing that the $a$th and $b$th crossing are connected by a road segment. Two crossings are connected by at most one road segment.
It is guaranteed that two road segments only intersect in a crossing they both start or end at. Further, it is guaranteed that each crossing on the map corresponds to an actual crossing in the sense that at least three road segments intersect.
Output
Output a single integer, the minimum number of crossings the racetrack must contain.
| Sample Input 1 | Sample Output 1 |
|---|---|
4 6 0 0 3 0 0 3 1 1 1 2 1 3 1 4 2 3 2 4 3 4 |
3 |
| Sample Input 2 | Sample Output 2 |
|---|---|
10 15 1 5 2 1 3 4 4 2 5 3 6 2 7 3 8 1 9 4 11 5 1 2 1 3 1 10 2 4 3 5 4 5 4 6 5 7 6 7 6 8 7 9 8 10 9 10 2 8 3 9 |
4 |
