#P3958. Jerry's Cheese Maze

    ID: 17206 Type: Default 1000ms 256MiB

Jerry's Cheese Maze

Jerry's Cheese Maze

Jerry, a clever mouse, finds himself at the bottom of an enormous cheese block of height \(h\) with infinite length and width. The cheese contains several spherical holes of identical radius \(r\). In a 3D coordinate system established within the cheese, the bottom surface is at \(z=0\) and the top surface at \(z=h\). Each hole is given by the coordinates of its center \((x,y,z)\).

Jerry can enter a hole if it touches or intersects the bottom surface (i.e. if \(z - r \le 0\)), and he can exit from a hole if it touches or intersects the top surface (i.e. if \(z + r \ge h\)). Furthermore, if two holes touch or intersect (their centers are within a distance of \(2r\), according to the distance formula \[ \mathrm{dist}(P_1,P_2)=\sqrt{(x_1-x_2)^2+(y_1-y_2)^2+(z_1-z_2)^2}, \] Jerry can run from one hole to the other.

Your task is to determine whether it is possible for Jerry to reach the top surface from the bottom surface by traversing through these connected holes without damaging the cheese.

inputFormat

The first line of input contains three numbers: \(h\) (the height of the cheese), \(r\) (the radius of every spherical hole), and \(n\) (the number of holes).

Each of the following \(n\) lines contains three space-separated numbers \(x\), \(y\), and \(z\), representing the coordinates of the center of a hole.

outputFormat

Output Yes if Jerry can reach the top surface from the bottom surface via the holes; otherwise, output No.

sample

10 3 3
0 0 2
0 0 5
0 0 8
Yes

</p>