Cave Crisis

Time limit1sMemory limit128 MB

Problem

R2D2 was exploring a tunnel when a cave-in suddenly occurred. Is he trapped?

Figure 1: Overhead view of a cave crisis scenario.

From an overhead view, every obstacle (a pile of debris) is visible on a two-dimensional Cartesian plane. The tunnel is $w$ cm wide and is bounded by the lines $y = w/2$ and $y = -w/2$. R2D2 starts at the origin $(0, 0)$ and has a perfectly circular footprint of radius $r$. The tunnel's exit lies to the right of the line $x = 1000$. Several polygonal obstacles lie between R2D2 and the exit.

Can R2D2 navigate between the obstacles and reach the exit?

Input

The input contains several test cases. Each test case begins with a line holding an even integer $w$ ($2 \le w \le 1000$), the width of the tunnel, and an integer $N$ ($0 \le N \le 100$), the number of obstacles. Each of the next $N$ lines describes one obstacle. The $i$-th obstacle is a simple polygon given on a single line as an integer $n_i$ ($3 \le n_i \le 10$), the number of vertices, followed by $n_i$ integer pairs $x_{ij}$ and $y_{ij}$ ($0 \le x_{ij} \le 1000$ and $-w/2 \le y_{ij} \le w/2$ for $j = 1, \dots, n_i$), the coordinates of the vertices in counterclockwise order.

Obstacles may touch or even overlap one another, but R2D2's starting location is guaranteed never to touch or overlap any obstacle. The vertices of each polygon are distinct, no two non-consecutive edges of a polygon intersect (not even at their endpoints), and every polygon has nonzero area.

The input ends with a line containing $w = N = 0$, which must not be processed.

Output

For each test case, determine the maximum radius $r > 0$ that R2D2 could have while still being able to plan a path from the start $(0, 0)$ to the tunnel exit without overlapping any obstacle. Print this maximum radius rounded to two decimal places, or the word impossible if no such radius exists.