#include<iostream>
#include<complex>

using namespace std;

typedef complex<double> P;

int W,H,N,R;
int x1[123],y_1[123],x2[123],y2[123],t[123];
double eps=1e-9;

double cross(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

pair<pair<P,P>,pair<P,P> > sl(P a1,P a2,double dd){
  P a=a2-a1;
  P d=a/abs(a)*P(0,1)*dd;
  return make_pair(make_pair(a1+d,a2+d),make_pair(a1-d,a2-d));
}

bool safe(pair<P,P> a,pair<P,P> b){
  P ad=a.second-a.first;
  P bd=b.second-b.first;
  double aa=cross(ad,bd);
  if(fabs(aa)<eps)return false;
  P is=a.first+ad/aa*cross(b.first-a.first,bd);
  //    cout<<is<<endl;
  if(is.real()<R-eps||W-R+eps<is.real()||is.imag()<R-eps||H-R+eps<is.imag())return false;
  for(int i=0;i<N;i++){
    P p1=P(x1[i],y_1[i]);
    P p=P(x2[i],y2[i])-p1;
    //    cout<<cross(is-p1,p)/abs(p)<<endl;
    if(fabs(cross(is-p1,p))/abs(p)<R+t[i]-eps)return false;
  }
  //  cout<<is<<endl;
  return true;
}

bool check(P a1,P a2,P b1,P b2){
  auto as=sl(a1,a2,R);
  auto bs=sl(b1,b2,R);
  return safe(as.first,bs.first)||safe(as.first,bs.second)||safe(as.second,bs.first)||safe(as.second,bs.second);
}
  
int main(){
  for(;cin>>W>>H>>N>>R,W|H|N|R;){
    bool f=!N;
    P p1[123][2],p2[123][2];
    for(int i=0;i<N;i++){
      cin>>x1[i]>>y_1[i]>>x2[i]>>y2[i]>>t[i];
      auto s=sl(P(x1[i],y_1[i]),P(x2[i],y2[i]),t[i]);
      p1[i][0]=s.first.first;
      p2[i][0]=s.first.second;
      p1[i][1]=s.second.first;
      p2[i][1]=s.second.second;
    }
    for(int i=0;i<N;i++){
      for(int j=0;j<2;j++){
	f|=check(p1[i][j],p2[i][j],P(0,0),P(W,0));
	f|=check(p1[i][j],p2[i][j],P(W,0),P(W,H));
	f|=check(p1[i][j],p2[i][j],P(W,H),P(0,H));
	f|=check(p1[i][j],p2[i][j],P(0,H),P(0,0));
	for(int k=0;k<i;k++){
	  for(int l=0;l<2;l++){
	    f|=check(p1[i][j],p2[i][j],p1[k][l],p2[k][l]);
	  }
	}
      }
    }
    cout<<(f?"Yes":"No")<<endl;
  }
}
### Prompt

Develop a solution in Cpp to the problem described below:

Nathan O. Davis is challenging a kind of shooter game. In this game, enemies emit laser beams from outside of the screen. A laser beam is a straight line with a certain thickness. Nathan moves a circular-shaped machine within the screen, in such a way it does not overlap a laser beam. As in many shooters, the machine is destroyed when the overlap happens.

Nathan is facing an uphill stage. Many enemies attack simultaneously in this stage, so eventually laser beams fill out almost all of the screen. Surprisingly, it is even possible he has no "safe area" on the screen. In other words, the machine cannot survive wherever it is located in some cases.

The world is as kind as it is cruel! There is a special item that helps the machine to survive any dangerous situation, even if it is exposed in a shower of laser beams, for some seconds. In addition, another straight line (called "a warning line") is drawn on the screen for a few seconds before a laser beam is emit along that line.

The only problem is that Nathan has a little slow reflexes. He often messes up the timing to use the special item. But he knows a good person who can write a program to make up his slow reflexes - it's you! So he asked you for help.

Your task is to write a program to make judgement whether he should use the item or not, for given warning lines and the radius of the machine.



Input

The input is a sequence of datasets. Each dataset corresponds to one situation with warning lines in 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 of a dataset contains four integers W, H, N and R (2 < W ≤ 640, 2 < H ≤ 480, 0 ≤ N ≤ 100 and 0 < R < min{W, H}/2). The first two integers W and H indicate the width and height of the screen, respectively. The next integer N represents the number of laser beams.

The last integer R indicates the radius of the machine. It is guaranteed that the output would remain unchanged if the radius of the machine would become larger by 10-5 than R.

The following N lines describe the N warning lines. The (i+1)-th line of the dataset corresponds to the i-th warning line, which is represented as a straight line which passes through two given different coordinates (xi,1, yi,1 ) and (xi,2 , yi,2 ). The last integer ti indicates the thickness of the laser beam corresponding to the i-th warning line.

All given coordinates (x, y) on the screen are a pair of integers (0 ≤ x ≤ W, 0 ≤ y ≤ H). Note that, however, the machine is allowed to be located at non-integer coordinates during the play.

The input is terminated by a line with four zeros. This line should not be processed.

Output

For each case, print "Yes" in a line if there is a safe area, or print "No" otherwise.

Example

Input

100 100 1 1
50 0 50 100 50
640 480 1 1
0 0 640 480 100
0 0 0 0


Output

No
Yes

### Response

```cpp
#include<iostream>
#include<complex>

using namespace std;

typedef complex<double> P;

int W,H,N,R;
int x1[123],y_1[123],x2[123],y2[123],t[123];
double eps=1e-9;

double cross(P a,P b){
  return a.real()*b.imag()-a.imag()*b.real();
}

pair<pair<P,P>,pair<P,P> > sl(P a1,P a2,double dd){
  P a=a2-a1;
  P d=a/abs(a)*P(0,1)*dd;
  return make_pair(make_pair(a1+d,a2+d),make_pair(a1-d,a2-d));
}

bool safe(pair<P,P> a,pair<P,P> b){
  P ad=a.second-a.first;
  P bd=b.second-b.first;
  double aa=cross(ad,bd);
  if(fabs(aa)<eps)return false;
  P is=a.first+ad/aa*cross(b.first-a.first,bd);
  //    cout<<is<<endl;
  if(is.real()<R-eps||W-R+eps<is.real()||is.imag()<R-eps||H-R+eps<is.imag())return false;
  for(int i=0;i<N;i++){
    P p1=P(x1[i],y_1[i]);
    P p=P(x2[i],y2[i])-p1;
    //    cout<<cross(is-p1,p)/abs(p)<<endl;
    if(fabs(cross(is-p1,p))/abs(p)<R+t[i]-eps)return false;
  }
  //  cout<<is<<endl;
  return true;
}

bool check(P a1,P a2,P b1,P b2){
  auto as=sl(a1,a2,R);
  auto bs=sl(b1,b2,R);
  return safe(as.first,bs.first)||safe(as.first,bs.second)||safe(as.second,bs.first)||safe(as.second,bs.second);
}
  
int main(){
  for(;cin>>W>>H>>N>>R,W|H|N|R;){
    bool f=!N;
    P p1[123][2],p2[123][2];
    for(int i=0;i<N;i++){
      cin>>x1[i]>>y_1[i]>>x2[i]>>y2[i]>>t[i];
      auto s=sl(P(x1[i],y_1[i]),P(x2[i],y2[i]),t[i]);
      p1[i][0]=s.first.first;
      p2[i][0]=s.first.second;
      p1[i][1]=s.second.first;
      p2[i][1]=s.second.second;
    }
    for(int i=0;i<N;i++){
      for(int j=0;j<2;j++){
	f|=check(p1[i][j],p2[i][j],P(0,0),P(W,0));
	f|=check(p1[i][j],p2[i][j],P(W,0),P(W,H));
	f|=check(p1[i][j],p2[i][j],P(W,H),P(0,H));
	f|=check(p1[i][j],p2[i][j],P(0,H),P(0,0));
	for(int k=0;k<i;k++){
	  for(int l=0;l<2;l++){
	    f|=check(p1[i][j],p2[i][j],p1[k][l],p2[k][l]);
	  }
	}
      }
    }
    cout<<(f?"Yes":"No")<<endl;
  }
}
```