You are given a set of circles of a variety of radii placed at a variety of positions, possibly overlapping one another. Given a circle with radius , that circle may be placed so that it encircles all of the circles in the set if is large enough.
There may be more than one possible position of the circle of radius to encircle all the member circles of . We define the region as the union of the areas of encircling circles at all such positions. In other words, for each point in , there exists a circle of radius that encircles that point and all the members of . Your task is to calculate the length of the periphery of that region .
Figure 1 shows an example of the set of circles and the region . In the figure, three circles contained in are expressed by circles of solid circumference, some possible positions of the encircling circles are expressed by circles of dashed circumference, and the area is expressed by a thick dashed closed curve.
\includegraphics{https://static.e-olymp.com/content/34/345843c0fd2310bffa335efd4cfe8f78ab5c82ed.jpg}
Figure 1. Example of the Circle Set
The input is a sequence of datasets. The number of datasets is less than .
Each dataset is formatted as follows.
x_1 y_1 r_1x_2 y_2 r_2...x_n y_n r_n
The first line of a dataset contains two positive integers, and , separated by a single space. means the number of the circles in the set and does not exceed . means the radius of the encircling circle and does not exceed .
Each of the lines following the first line contains three integers separated by a single space. (x_i, y_i) means the center position of the -th circle of the set and r_i means its radius.
You may assume -500 \le x_i \le 500, -500 \le y_i \le 500, and 1 \le r_i \le 500.
The end of the input is indicated by a line containing two zeros separated by a single space.
For each dataset, output a line containing a decimal fraction which means the length of the periphery (circumferential length) of the region .
The output should not contain an error greater than . You can assume that, when changes by (|\epsilon| < 0.0000001), the length of the periphery of the region will not change more than .
If is too small to cover all of the circles in , output a line containing only .
No other characters should be contained in the output.
\includegraphics{https://static.e-olymp.com/content/35/35cd782d4a64cfbe626f0635cc628e323184c2ed.jpg}
Figure 2. Last Dataset of the Sample Input
Мысал 1