#P6857. 「ICPC World Finals 2021」俯瞰岛屿

「ICPC World Finals 2021」俯瞰岛屿

Description

You might never have heard of the island group of Iceepeecee, but that suits their inhabitants just fine. Located in a remote part of the South Pacific, they are truly off the beaten track, without any regular air or sea traffic, and they have remained a tropical paradise with unspoiled local fauna and flora.

Being off the map is great when you don't want to be overrun by hordes of tourists, but not so ideal when you actually do need a map for some reason. One such reason came up recently: Iceepeecee's central government needs an exact map of the islands to apportion government funds. Even tropical paradises need money, so Iceepeecee needs a map!

The easiest way to create a map would be an aerial survey. After dismissing chartering planes as too expensive, building an air balloon as too dangerous, and fitting carrier pigeons with cameras as too cruel to animals, they had a brilliant idea. Even with its remote location, there are still plenty of commercial airplanes crossing the skies above Iceepeecee. What if one mounted cameras on flights that are already scheduled to fly anyway? That would be a cheap solution to the problem!

Iceepeecee's plan is to install line-scan cameras on the planes. These cameras point straight downwards and collect images one line segment at a time, orthogonal to the flight path. The photographed line segment will be determined by the altitude that the plane is flying at, and the camera's aperture angle θ\theta (see Figure F.1). Greater angles θ\theta mean that the camera can see more, but also that the camera is more expensive.

F1.png

Figure F.1 A view of the plane, shown head-on. Its camera points downward and can see the part of the ground underneath the plane that is shown in green. How much is visible depends on the aperture angle θ.

Moreover, Iceepeecee wants to make sure that each island is observed in its entirety by at least one flight. That means it is not sufficient that an island is only partially photographed by multiple flights, even if the combination of the photographs covers the whole island.

Flight paths follow straight line segments in three-dimensional space, that is, (x1,y1,z1)(x2,y2,z2)(x_1, y_1, z_1) - (x_2, y_2, z_2) (see Figure F.2), where the zz-coordinates give the altitude of the plane. Photographs are taken only along these line segments.

F2a.png

(a) Three islands (shown in black) and two flight paths (red and green). Altitudes are not shown.

F2b.png

(b) The shaded areas represent the ground visible on the two flight paths for an optimally chosen θ.
Figure F.2 Surveying three islands via two flight paths. This corresponds to the first sample input.

Given the location of their islands and flights, Iceepeecee wants to find the smallest aperture angle θ\theta that allows for a successful survey. Can you help?

Input

The input describes a set of islands and flight paths. It starts with a line containing two integers nn and mm, the number nn of islands, and the number mm of flight paths, respectively (1n,m1001 \le n, m \le 100). This is followed by descriptions of the nn islands. Each island description starts with a line containing a single integer nin_i, the number of vertices of the polygon describing the ithi^\text{th} island (3ni1003 \le n_i \le 100). It is followed by nin_i lines, each containing two integers xijx_{ij}, yijy_{ij} (xij,yij106|x_{ij}|, |y_{ij}| \le 10^6), specifying the vertices for the ith island in counterclockwise order. Each island's polygon is simple, that is, its vertices are distinct and no two edges of the polygon intersect or touch, other than consecutive edges which touch at their common vertex. Different islands do not intersect or touch.

The input concludes with another mm lines, each describing a flight path. Each such line contains six integers x1,y1,z1,x2,y2,z2x_1, y_1, z_1, x_2, y_2, z_2 (xi,yi,zi106|x_i|, |y_i|, |z_i| \le 10^6, zi>0z_i > 0 and (x1,y1)(x2,y2)(x_1, y_1) \neq (x_2, y_2)). They specify that a flight takes place from (x1,y1,z1)(x_1, y_1, z_1) to (x2,y2,z2)(x_2, y_2, z_2).

Output

Output the smallest angle θ\theta (in degrees) that allows for a complete survey of the islands with the given flights. The answer should be exact to an absolute or relative error of 10610^{-6}. If there is no such angle, then output impossible. The input is chosen such that if the coordinates of the island vertices are changed by at most ±108\pm 10^{-8}, then the answer will not change more than the allowed rounding error.

3 2
3
20 30
50 50
10 50
4
40 20
60 10
75 20
60 30
4
45 60
55 55
60 60
55 65
0 30 20 78 70 5
55 0 20 70 60 10

48.031693036

1 1
4
0 0
10 0
10 10
0 10
5 5 10 15 5 10

impossible