Universal socket
The electrical outlet is configured with two contacts, each linked to a wire. These contacts, along with their respective wires, are traditionally referred to as "phase" and "neutral." The outlet's outer panel features two holes designed for connecting electrical devices.
Devices connect to the outlet using plugs, which have two contacts that fit into the outlet's holes. When a plug is inserted, its contacts align with those of the outlet, completing the circuit.
Globally, plugs vary in the distance between their contacts, posing challenges for travelers. To address this, a major company plans to launch a universal outlet that accommodates plugs from nearly any country. This outlet features n holes, some connected to neutral and others to phase.
Your task is to determine if a plug with a contact distance of d can be connected to this outlet such that one contact connects to neutral and the other to phase.
Input
The first line provides two integers n and d (1 ≤ n ≤ 200, 1 ≤ d ≤ 10000).
Consider a rectangular Cartesian coordinate system on the outlet's outer panel. The next n lines each contain three integers x[i]
, y[i]
, t[i]
(-10000 ≤ x[i]
, y[i]
≤ 10000; 0 ≤ t[i]
≤ 1). These indicate a hole at coordinates x[i]
, y[i]
. If t[i]
= 1, the hole is connected to phase; if t[i]
= 0, it is connected to neutral.
All holes are at unique coordinates.
Output
Print Yes if the plug can be correctly connected to the outlet, and No otherwise.