Well-Oiled Machine
As the greatest inventor in Adelaide, you love building little contraptions out of cogs. However, it's hard to tell what they'll do until you put them together!
Your designs contain cogs, repreesented by circles with position
and radius
. Any cogs that are touching or intersecting will spin in opposite directions.
However, some arrangements of cogs can't spin, because they are being pulled two different ways. For example, a circle of three cogs can't spin:
For any given design of cogs, are all of the cogs able to spin?
Input
The first line of each test case contains an a single integer , the number of cogs in your design.
The next lines contain 3 integers
, indicating that there is a cog at the position
with radius
.
.
Output
For each test case, print "Yes" if all the cogs are able to spin, and "No" if they can't.
Note: It's possible that not all cogs in a test case are touching/intersecting.
Note: It's impossible for one cog to be completely inside another.
Example
Input
5
1 1 1
3 2 2
5 1 1
6 1 1
7 6 1
Output
Yes
See the diagram below for a picture of the cogs. All the red ones can spin clockwise, and all the blue ones can spin counterclockwise.
Example
Input
3
1 1 2
3 2 2
2 3 2
Output
No
Comments