Under construction

Still being built. Things may change

Island Travel

Time limit2sMemory limit1024 MB

Summary
Find the minimum flying distance from island a to island b, where Hiccup can walk freely across each convex polygon island.
Level

Medium7 of 10

Topics
Shortest path, Geometry
Solved
No attempts yet

Statement

Hiccup and Toothless find themselves in the middle of an archipelago. The archipelago has nn islands. Seen from a bird's-eye view, each island is a convex polygon. No two islands share a point. The islands are numbered from 11 to nn. Hiccup is on island aa and urgently needs to reach island bb.

Hiccup and Toothless can walk freely on any island. To get from one island to another, Toothless has to fly. Toothless can take off from any point on any island, fly along any route, and land at any point on any island. The distance he flies equals the length of that route. Toothless is very tired, so Hiccup wants to minimize the distance Toothless flies. Help him find this distance.

Input

The first line contains three integers nn, aa, and bb: the number of islands, the island where Hiccup starts, and the island where he wants to go (1≤n≤2001 \le n \le 200, 1≤a,b≤n1 \le a, b \le n).

Each island description starts with an integer kik_i, the number of vertices of the polygon for the ii-th island (3≤ki≤5003 \le k_i \le 500). The next kik_i lines each contain two integers xi,jx_{i,j} and yi,jy_{i,j}, the coordinates of the jj-th vertex of the ii-th polygon (−109≤xi,yi≤109-10^9 \le x_i, y_i \le 10^9). Vertices are given in counterclockwise order. No three consecutive vertices lie on one line.

The islands are numbered from 11 to nn in the order they appear in the input. It is guaranteed that no two polygons share a point.

Output

Print one real number: the minimum distance Toothless must fly so that Hiccup can get from island aa to island bb. The answer is accepted if its absolute or relative error does not exceed 10−910^{-9}.

Hint

The first figure shows the part of the route that Hiccup and Toothless walk in orange, and the part that Toothless flies in blue.

The second figure is shown below.

Examples2

  1. Example 1

    Input
    4 1 3
    3
    0 1
    0 0
    1 0
    3
    2 0
    3 0
    3 1
    3
    3 2
    3 3
    2 3
    3
    1 3
    0 3
    0 2
    
    Expected output
    2.000000000000000
    
  2. Example 2

    Input
    2 1 2
    4
    2 1
    3 2
    2 3
    1 3
    4
    4 2
    5 2
    4 4
    3 3
    
    Expected output
    0.707106781186548