QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100 Difficulty: [show] Hackable ✓

#13846. Cheese

Statistics

There is a piece of cheese with height $h$. Its length and width can be considered infinite. There are many spherical holes of the same radius $r$ inside the cheese. We can establish a 3D coordinate system in this cheese, where the bottom surface of the cheese is $z = 0$ and the top surface is $z = h$.

Currently, there is a mouse named Jerry on the bottom surface of the cheese. He knows the coordinates of the centers of all the spherical holes in the cheese. If two holes are tangent or intersecting, Jerry can run from one hole to the other. Specifically, if a hole is tangent to or intersecting the bottom surface, Jerry can run from the bottom surface into that hole; if a hole is tangent to or intersecting the top surface, Jerry can run from that hole to the top surface.

Jerry, who is located on the bottom surface of the cheese, wants to know if he can reach the top surface of the cheese using the existing holes without breaking the cheese.

The distance formula between two points $P_1(x_1, y_1, z_1)$ and $P_2(x_2, y_2, z_2)$ in space is:

$$\text{dist}(P_1, P_2) = \sqrt{(x_1 - x_2)^2 + (y_1 - y_2)^2 + (z_1 - z_2)^2}$$

Input

The first line contains a positive integer $T$, representing the number of data sets in the input file.

Following this are $T$ data sets. Each data set is formatted as follows:

The first line contains three positive integers $n$, $h$, and $r$, separated by spaces, representing the number of holes in the cheese, the height of the cheese, and the radius of the holes, respectively.

The next $n$ lines each contain three integers $x, y, z$, separated by spaces, representing the coordinates $(x, y, z)$ of the center of a spherical hole.

Output

The output contains $T$ lines, each corresponding to the answer for the $i$-th data set. If Jerry can run from the bottom surface to the top surface in the $i$-th data set, output "Yes"; otherwise, output "No" (excluding the quotes).

Examples

Input 1

3
2 4 1
0 0 1
0 0 3
2 5 1
0 0 1
0 0 4
2 5 2
0 0 2
2 0 4

Output 1

Yes
No
Yes

Note

For the first data set: The first hole at $(0, 0, 1)$ is tangent to the bottom surface. The second hole at $(0, 0, 3)$ is tangent to the top surface. The two holes are tangent to each other at $(0, 0, 2)$. Output: Yes

For the second data set: The two holes neither intersect nor are tangent to each other. Output: No

For the third data set: The two holes intersect and are tangent to/intersect the top and bottom surfaces. Output: Yes

Constraints

  • For 20% of the data: $n = 1$, $1 \le h, r \le 10,000$, absolute values of coordinates do not exceed $10,000$.
  • For 40% of the data: $1 \le n \le 8$, $1 \le h, r \le 10,000$, absolute values of coordinates do not exceed $10,000$.
  • For 80% of the data: $1 \le n \le 1,000$, $1 \le h, r \le 10,000$, absolute values of coordinates do not exceed $10,000$.
  • For 100% of the data: $1 \le n \le 1,000$, $1 \le h, r \le 1,000,000,000$, $T \le 20$, absolute values of coordinates do not exceed $1,000,000,000$.

Figure 1. Illustration of the first data set where holes are connected and reach the top and bottom surfaces.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.