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
#include<bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pi M_PI
#define inf 1<<30
#define eps (1e-10)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}

  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1=Point(),Point p2=Point()):p1(p1),p2(p2){}
};
typedef Segment Line;

class Circle{
public:
  Point c;
  double r;
  Circle(Point c=Point(),double r=0.0):c(c),r(r){}
};

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

bool isParallel(Vector a,Vector b){
  return equals(cross(a,b),0.0);
}

Point getCrossPointLL(Line a,Line b){
  double A=cross(a.p2-a.p1,b.p2-b.p1);
  double B=cross(a.p2-a.p1,a.p2-b.p1);
  if(abs(A)<eps || abs(B)<eps)return b.p1;
  return b.p1+(b.p2-b.p1)*(B/A);
}

// Vector???90????????¢
Vector rotateVector90(Vector v){
  swap(v.x,v.y);
  v.y*=-1;
  return v;
}

// dis??????Line??????????§????
pair<Line,Line> getParalellLine(Line L,double dis){
  Vector v=L.p2-L.p1;
  v=rotateVector90(v);
  v=(v*dis)/abs(v);
  return mp(Line(L.p1+v,L.p2+v),Line(L.p1-v,L.p2-v));
}

double getDistanceLP(Line l,Point p){
  return abs(cross(l.p2-l.p1,p-l.p1)/abs(l.p2-l.p1));
}

Point rotate(Point base,Point a,double r){
  Point b=a-base;
  a.x=b.x*cos((r/180)*M_PI)-b.y*sin((r/180)*M_PI);
  a.y=b.x*sin((r/180)*M_PI)+b.y*cos((r/180)*M_PI);
  a=a+base;
  return a;
}

int h,w,n;
vector<pair<Line,double> > vl;
vector<pair<Line,Line> > vpl;
vector<Line> vs;

bool in(Circle c){
  double disa=c.c.x-c.r,disb=c.c.x+c.r,disc=c.c.y-c.r,disd=c.c.y+c.r;
  if(disa<-eps || (w-disa)<-eps)return false;
  if(disb<-eps || (w-disb)<-eps)return false;
  if(disc<-eps || (h-disc)<-eps)return false;
  if(disd<-eps || (h-disd)<-eps)return false;
  return true;
}

bool check(Circle c){
  if(!in(c))return false;
  for(int i=0;i<n;i++){
    double dis=getDistanceLP(vl[i].f,c.c);
    if((dis-(c.r+vl[i].s))<-eps)return false;
  }
  return true;
}

bool check(Line L1,Line L2,double R){
  if(isParallel(L1.p1-L1.p2,L2.p1-L2.p2))return false;
  Point origin=getCrossPointLL(L1,L2),temp;
  Point p1=L1.p1,p2=L2.p1;
  Vector v1,v2,v3;
  double s,x;

  if(equals(abs(L1.p1-origin),0.0))p1=L1.p2;
  if(equals(abs(L2.p1-origin),0.0))p2=L2.p2;

  v1=p1-origin,v2=p2-origin;
  s=acos(dot(v1,v2)/(abs(v1)*abs(v2)))/2.0;
  x=(R/sin(s));
  v3=rotate(origin,p1,180-(s*360/(2*pi)))-origin;
  v3=v3*x/abs(v3);
  temp=origin+v3;
  //printf("%.10f %.10f %.10f\n",temp.x,temp.y,R);
  if(check(Circle(origin+v3,R)))return true;

  p1=rotate(origin,p1,180);
  v1=p1-origin,v2=p2-origin;
  s=acos(dot(v1,v2)/(abs(v1)*abs(v2)))/2.0;
  x=(R/sin(s));
  v3=rotate(origin,p2,180-(s*360/(2*pi)))-origin;
  v3=v3*x/abs(v3);
  temp=origin+v3;
  //printf("%.10f %.10f %.10f\n",temp.x,temp.y,R);
  if(check(Circle(origin+v3,R)))return true;

  p2=rotate(origin,p2,180);
  v1=p1-origin,v2=p2-origin;
  s=acos(dot(v1,v2)/(abs(v1)*abs(v2)))/2.0;
  x=(R/sin(s));
  v3=rotate(origin,p1,180-(s*360/(2*pi)))-origin;
  v3=v3*x/abs(v3);
  temp=origin+v3;
  //printf("%.10f %.10f %.10f\n",temp.x,temp.y,R);
  if(check(Circle(origin+v3,R)))return true;

  p1=rotate(origin,p1,180);
  v1=p1-origin,v2=p2-origin;
  s=acos(dot(v1,v2)/(abs(v1)*abs(v2)))/2.0;
  x=(R/sin(s));
  v3=rotate(origin,p2,180-(s*360/(2*pi)))-origin;
  v3=v3*x/abs(v3);
  temp=origin+v3;
  //printf("%.10f %.10f %.10f\n",temp.x,temp.y,R);
  if(check(Circle(origin+v3,R)))return true;

  return false;
}

int main()
{
  int a,b,c,d,e,R;

  while(1){
    cin>>w>>h>>n>>R;
    if(h+w+n+R==0)break;
    vs.clear();
    vl.clear();
    vpl.clear();
    vs.push_back(Line(Point(0,0),Point(0,h)));
    vs.push_back(Line(Point(0,h),Point(w,h)));
    vs.push_back(Line(Point(w,h),Point(w,0)));
    vs.push_back(Line(Point(w,0),Point(0,0)));

    for(int i=0;i<n;i++){
      cin>>a>>b>>c>>d>>e;
      Line L=Line(Point(a,b),Point(c,d));
      vl.push_back(mp(L,e));
      vpl.push_back(getParalellLine(L,e));
    }
    
    string ans="No";
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	if(check(vpl[i].f,vpl[j].f,R))ans="Yes";
	if(check(vpl[i].f,vpl[j].s,R))ans="Yes";
	if(check(vpl[i].s,vpl[j].f,R))ans="Yes";
	if(check(vpl[i].s,vpl[j].s,R))ans="Yes";
      }
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<4;j++){
	if(check(vpl[i].f,vs[j],R))ans="Yes";
	if(check(vpl[i].s,vs[j],R))ans="Yes";      
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}