410585: GYM104059 F Formula Flatland
Description
Flatland is happy to announce that this year – for the first time ever – the Formula One comes to Flatland to arrange the Grand Prix of Flatland. As with many other cities, Flatland is not able to build a dedicated circuit for the race. Therefore, Flatland decided to close off some of its normal streets and crossings to form a circuit. After your excellent work as an organizer of last year's Flatland Olympics, you were hired to find a suitable circuit. Since closed off streets are annoying to the people who live there, you would like to minimize the number of crossings that need to be closed off for the race.
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.
InputThe input consists of:
- One line with two integers $$$n$$$ and $$$m$$$ ($$$4\leq n \leq10^5\text{ and }5\leq m\leq3\cdot10^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\leq10^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.
Output a single integer, the minimum number of crossings the racetrack must contain.
ExamplesInput4 6 0 0 3 0 0 3 1 1 1 2 1 3 1 4 2 3 2 4 3 4Output
3Input
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 9Output
4