#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

#define EPS (1e-8)
#define eq(a, b) (fabs((a)-(b)) < EPS)
#define lt(a, b) ((a) - (b) < -EPS)
#define le(a, b) (eq(a, b) || lt(a, b))

struct Point {
  double x, y;
  Point(double x = 0.0, double y = 0.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 a) { return Point(x * a, y * a); }
  Point operator / (double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() { return x*x + y*y; }

  bool operator < (const Point& p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == (const Point& p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};
typedef Point Vector;

double norm(Vector v) { return v.x*v.x + v.y*v.y; }
double abs(Vector v) { return sqrt(norm(v)); }
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 isOrthogonal(Vector a, Vector b) {
  return eq(dot(a, b), 0.0);
}
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {
  return isOrthogonal(a1 - a2, b1 - b2);
}
bool isParallel(Vector a, Vector b) {
  return eq(cross(a, b), 0.0);
}
bool isParallel(Point a1, Point a2, Point b1, Point b2) {
  return isParallel(a1 - a2, b1 - b2);
}

#define COUNTER_CLOCKWISE +1
#define CLOCKWISE         -1
#define ONLINE_BACK       +2
#define ONLINE_FRONT      -2
#define ON_SEGMENT        +0
int ccw(Point p0, Point p1, Point p2) {
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if(cross(a, b) > EPS) return COUNTER_CLOCKWISE;
  if(cross(a, b) < -EPS) return CLOCKWISE;
  if(dot(a, b) < -EPS) return ONLINE_BACK;
  if(a.norm() < b.norm()) return ONLINE_FRONT;
  return ON_SEGMENT;
}
bool intersect(Point p1, Point p2, Point p3, Point p4) {
  return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
	  ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}
double getDistance(Point a, Point b) { return abs(a - b); }

struct Segment {
  Point s, t;
  Segment(Point s = Point(), Point t = Point()):s(s), t(t){}
};
typedef Segment Line;

bool intersect(Segment s1, Segment s2) {
  return intersect(s1.s, s1.t, s2.s, s2.t);
}
bool isParallel(Line s1, Line s2) {
  return isParallel(s1.s, s1.t, s2.s, s2.t);
}
double getDistanceLP(Line l, Point p) {
  return abs(cross(l.t - l.s, p - l.s) / abs(l.t - l.s));
}
Point getCrossPointLL(Line l1, Line l2) {
  Vector v1 = l1.t - l1.s, v2 = l2.t - l2.s;
  double d = cross(v2, v1);
  if(abs(d) < EPS) return l2.s;
  return l1.s + v1 * cross(v2, l2.t - l1.s) * (1.0 / d);
}
vector<Vector> getNormalLineVector(Line l) {
  vector<Vector> vs;
  Vector v = l.t - l.s, p = v / abs(v);
  vs.emplace_back(-p.y, p.x);
  vs.emplace_back(p.y, -p.x);
  return vs;
}
vector<Line> getTranslation(Line l, double d) {
  vector<Vector> nlv = getNormalLineVector(l);
  vector<Line> nl;
  nl.emplace_back(l.s + nlv[0]*d, l.t + nlv[0]*d);
  nl.emplace_back(l.s + nlv[1]*d, l.t + nlv[1]*d);
  return nl;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int W, H, N, R;
  while(cin >> W >> H >> N >> R, W) {
    vector<Line> beam;
    vector<double> thick;
    beam.push_back(Line(Point(0, 0), Point(W, 0)));
    thick.push_back(0);
    beam.push_back(Line(Point(0, 0), Point(0, H)));
    thick.push_back(0);
    beam.push_back(Line(Point(W, H), Point(W, 0)));
    thick.push_back(0);
    beam.push_back(Line(Point(W, H), Point(0, H)));
    thick.push_back(0);
    vector<Line> war;
    war.push_back(Line(Point(R, R), Point(W-R, R)));
    war.push_back(Line(Point(R, R), Point(R, H-R)));
    war.push_back(Line(Point(W-R, H-R), Point(W-R, R)));
    war.push_back(Line(Point(W-R, H-R), Point(R, H-R)));
    rep(i, N) {
      Point p, q;
      double t;
      cin >> p.x >> p.y >> q.x >> q.y >> t;
      beam.push_back(Line(p, q));
      thick.push_back(t);
      auto L = getTranslation(beam.back(), t+R);
      for(auto&& l : L) war.push_back(l);//, cout<<l.s.x<<","<<l.s.y<<" "<<l.t.x<<","<<l.t.y<<endl;
    }
    auto in = [&](Point p) {
      //return 0<=p.x&&p.x<=W&&0<=p.y&&p.y<=H;
      return le(0,p.x)&&le(p.x,W)&&le(0,p.y)&&le(p.y,H);
    };
    auto check = [&](Point p) {
      if(!in(p)) return false;
      rep(i, beam.size()) {
	double d = getDistanceLP(beam[i], p) - thick[i];
	if(lt(d, R)) return false;
      }
      return true;
    };
    bool flag = false;
    for(auto&& l1 : war) {
      for(auto&& l2 : war) {
	if(isParallel(l1, l2)) continue;
	Point p = getCrossPointLL(l1, l2);
	if(check(p)) {
	  //cout << p.x<<" "<<p.y<<endl;
	  flag = true;
	  break;
	}
      }
      if(flag) break;
    }
    cout << (flag ? "Yes" : "No") << endl;
  }

  return 0;
}
### Prompt

Generate a CPP solution to the following problem:

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 <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

#define EPS (1e-8)
#define eq(a, b) (fabs((a)-(b)) < EPS)
#define lt(a, b) ((a) - (b) < -EPS)
#define le(a, b) (eq(a, b) || lt(a, b))

struct Point {
  double x, y;
  Point(double x = 0.0, double y = 0.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 a) { return Point(x * a, y * a); }
  Point operator / (double a) { return Point(x / a, y / a); }

  double abs() { return sqrt(norm()); }
  double norm() { return x*x + y*y; }

  bool operator < (const Point& p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
  bool operator == (const Point& p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};
typedef Point Vector;

double norm(Vector v) { return v.x*v.x + v.y*v.y; }
double abs(Vector v) { return sqrt(norm(v)); }
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 isOrthogonal(Vector a, Vector b) {
  return eq(dot(a, b), 0.0);
}
bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {
  return isOrthogonal(a1 - a2, b1 - b2);
}
bool isParallel(Vector a, Vector b) {
  return eq(cross(a, b), 0.0);
}
bool isParallel(Point a1, Point a2, Point b1, Point b2) {
  return isParallel(a1 - a2, b1 - b2);
}

#define COUNTER_CLOCKWISE +1
#define CLOCKWISE         -1
#define ONLINE_BACK       +2
#define ONLINE_FRONT      -2
#define ON_SEGMENT        +0
int ccw(Point p0, Point p1, Point p2) {
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if(cross(a, b) > EPS) return COUNTER_CLOCKWISE;
  if(cross(a, b) < -EPS) return CLOCKWISE;
  if(dot(a, b) < -EPS) return ONLINE_BACK;
  if(a.norm() < b.norm()) return ONLINE_FRONT;
  return ON_SEGMENT;
}
bool intersect(Point p1, Point p2, Point p3, Point p4) {
  return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 &&
	  ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}
double getDistance(Point a, Point b) { return abs(a - b); }

struct Segment {
  Point s, t;
  Segment(Point s = Point(), Point t = Point()):s(s), t(t){}
};
typedef Segment Line;

bool intersect(Segment s1, Segment s2) {
  return intersect(s1.s, s1.t, s2.s, s2.t);
}
bool isParallel(Line s1, Line s2) {
  return isParallel(s1.s, s1.t, s2.s, s2.t);
}
double getDistanceLP(Line l, Point p) {
  return abs(cross(l.t - l.s, p - l.s) / abs(l.t - l.s));
}
Point getCrossPointLL(Line l1, Line l2) {
  Vector v1 = l1.t - l1.s, v2 = l2.t - l2.s;
  double d = cross(v2, v1);
  if(abs(d) < EPS) return l2.s;
  return l1.s + v1 * cross(v2, l2.t - l1.s) * (1.0 / d);
}
vector<Vector> getNormalLineVector(Line l) {
  vector<Vector> vs;
  Vector v = l.t - l.s, p = v / abs(v);
  vs.emplace_back(-p.y, p.x);
  vs.emplace_back(p.y, -p.x);
  return vs;
}
vector<Line> getTranslation(Line l, double d) {
  vector<Vector> nlv = getNormalLineVector(l);
  vector<Line> nl;
  nl.emplace_back(l.s + nlv[0]*d, l.t + nlv[0]*d);
  nl.emplace_back(l.s + nlv[1]*d, l.t + nlv[1]*d);
  return nl;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int W, H, N, R;
  while(cin >> W >> H >> N >> R, W) {
    vector<Line> beam;
    vector<double> thick;
    beam.push_back(Line(Point(0, 0), Point(W, 0)));
    thick.push_back(0);
    beam.push_back(Line(Point(0, 0), Point(0, H)));
    thick.push_back(0);
    beam.push_back(Line(Point(W, H), Point(W, 0)));
    thick.push_back(0);
    beam.push_back(Line(Point(W, H), Point(0, H)));
    thick.push_back(0);
    vector<Line> war;
    war.push_back(Line(Point(R, R), Point(W-R, R)));
    war.push_back(Line(Point(R, R), Point(R, H-R)));
    war.push_back(Line(Point(W-R, H-R), Point(W-R, R)));
    war.push_back(Line(Point(W-R, H-R), Point(R, H-R)));
    rep(i, N) {
      Point p, q;
      double t;
      cin >> p.x >> p.y >> q.x >> q.y >> t;
      beam.push_back(Line(p, q));
      thick.push_back(t);
      auto L = getTranslation(beam.back(), t+R);
      for(auto&& l : L) war.push_back(l);//, cout<<l.s.x<<","<<l.s.y<<" "<<l.t.x<<","<<l.t.y<<endl;
    }
    auto in = [&](Point p) {
      //return 0<=p.x&&p.x<=W&&0<=p.y&&p.y<=H;
      return le(0,p.x)&&le(p.x,W)&&le(0,p.y)&&le(p.y,H);
    };
    auto check = [&](Point p) {
      if(!in(p)) return false;
      rep(i, beam.size()) {
	double d = getDistanceLP(beam[i], p) - thick[i];
	if(lt(d, R)) return false;
      }
      return true;
    };
    bool flag = false;
    for(auto&& l1 : war) {
      for(auto&& l2 : war) {
	if(isParallel(l1, l2)) continue;
	Point p = getCrossPointLL(l1, l2);
	if(check(p)) {
	  //cout << p.x<<" "<<p.y<<endl;
	  flag = true;
	  break;
	}
      }
      if(flag) break;
    }
    cout << (flag ? "Yes" : "No") << endl;
  }

  return 0;
}
```