Safe Area

Given a rectangular screen, circular machine radius, and laser lines with thickness, decide if some circle center avoids all beams.

Medium6GeometryImplementationNo attempts yetTime limit8sMemory limit512 MB

Problem

The screen is the rectangle whose lower left corner is (0,0)(0, 0) and whose upper right corner is (W,H)(W, H). The player moves a machine shaped as a circle of radius RR, and the machine has to stay completely inside the screen.

Enemies fire laser beams from outside the screen. A warning line is drawn a few seconds before a beam is fired along it, so the path of every beam is known in advance. The ii-th warning line is the infinite straight line through the two distinct points (xi,1,yi,1)(x_{i,1}, y_{i,1}) and (xi,2,yi,2)(x_{i,2}, y_{i,2}), and the beam fired along that line covers every point whose distance to the line is at most tit_i.

The machine is destroyed once it overlaps a beam. A machine centred at (x,y)(x, y) therefore survives exactly when both of the following hold.

  • RxWRR \le x \le W - R and RyHRR \le y \le H - R.
  • For every ii, the distance from (x,y)(x, y) to the ii-th line is at least ti+Rt_i + R.

If at least one such position exists, the screen has a safe area. Given the warning lines and the radius of the machine, decide whether a safe area exists.

Input

The input is a sequence of datasets. Each dataset has the following format.

W H N R
x1,1 y1,1 x1,2 y1,2 t1
x2,1 y2,1 x2,2 y2,2 t2
...
xN,1 yN,1 xN,2 yN,2 tN

The first line contains four integers WW, HH, NN and RR (2<W6402 < W \le 640, 2<H4802 < H \le 480, 0N1000 \le N \le 100, 0<R<min(W,H)/20 < R < \min(W, H) / 2). WW and HH are the width and the height of the screen, NN is the number of laser beams, and RR is the radius of the machine.

The ii-th of the next NN lines contains the integer coordinates of two distinct points on the ii-th warning line, followed by the thickness tit_i of that beam (0ti10000 \le t_i \le 1000). Every coordinate is an integer point on the screen (0xW0 \le x \le W, 0yH0 \le y \le H). The centre of the machine may sit at non-integer coordinates.

There are at most 50 datasets, and the last line of the input is 0 0 0 0. Do not process that line.

In every dataset the answer stays the same if the radius of the machine grows by 10510^{-5}.

Output

For each dataset, print Yes on one line if a safe area exists, and No otherwise.