Find the shortest single segment that connects the Sinchon road network to the Anam road network.
Medium5GeometryBrute forceNo attempts yetTime limit7sMemory limit256 MBYeondol and Gojam have been close friends since kindergarten. One bad decision later, meeting up became hard for them, because there is no way to get from Sinchon to Anam. The minister of land and transport felt sorry for the two and agreed to build one new road. The budget is tight, so the new road must be as short as possible.
You are given the roads connected to Sinchon and the roads connected to Anam on a two dimensional plane. Each road is the segment between its two endpoints. Yeondol moves only along roads, and switches roads at a point where two roads meet. The new road is a single segment as well.
Find the minimum length of a new road that makes Anam reachable from Sinchon.
The first line contains the number of roads connected to Sinchon, n, and the number of roads connected to Anam, m. (1≤n,m≤2000)
Each of the next n lines contains xs, ys, xe, ye describing a Sinchon road. (−10000≤xs,ys,xe,ye≤10000) The endpoints of that road are (xs,ys) and (xe,ye).
Each of the following m lines describes an Anam road in the same format. (−50000≤xs,ys,xe,ye≤50000)
Every coordinate has at most 20 digits after the decimal point.
For any two roads connected to Sinchon you can travel from one to the other, and the same holds for any two roads connected to Anam. Before the new road is built, you cannot start on a Sinchon road and arrive on an Anam road.
Print on one line the minimum length the new road must have so that Anam becomes reachable from Sinchon.
Round at the seventh digit after the decimal point and print all six decimal digits.