program aaa;

{$APPTYPE CONSOLE}

const
  eps = 1e-10;

var
  n, r, i, nn, j, tp, bt, lf, rt: integer;
  x, y, rr: extended;
  xx,yy,rd: array [1..500] of extended;
  a: array [1..500+5,0..500+5] of integer;
  v: array [1..500+5] of byte;

procedure dfs(u:integer);
 var
   i: integer;
begin
  v[u]:= 1;
  for i:=1 to a[u,0] do
    if v[a[u,i]]=0 then dfs(a[u,i]);
end;

begin
//  reset(input,'input.txt');
//  rewrite(output,'output.txt');

  readln(n,r); nn:= 0;
  for i:=1 to n do begin
    readln(x,y,rr);
    if (sqrt(sqr(x-r)+sqr(y-r))-r-rr>-eps) and (x<r) and (y<r) then continue;
    if (sqrt(sqr(x-1000+r)+sqr(y-1000+r))-r-rr>-eps) and (x>1000-r) and (y>1000-r) then continue;
    inc(nn);
    xx[nn]:= x; yy[nn]:= y; rd[nn]:= rr;
  end;
  n:= nn;

  fillchar(a,sizeof(a),0);
  for i:=1 to n-1 do
    for j:=i+1 to n do
      if sqrt(sqr(xx[i]-xx[j])+sqr(yy[i]-yy[j]))-rd[i]-rd[j]-2*r < -eps then begin
        inc(a[i,0]); a[i,a[i,0]]:= j;
        inc(a[j,0]); a[j,a[j,0]]:= i;
      end;

  tp:= n+1; bt:= n+2; lf:= n+3; rt:= n+4;
  for i:=1 to n do begin
    if yy[i]-rd[i]-2*r < -eps then begin
      inc(a[i,0]); a[i,a[i,0]]:= bt;
      inc(a[bt,0]); a[bt,a[bt,0]]:= i;
    end;
    if 1000-yy[i]-rd[i]-2*r < -eps then begin
      inc(a[i,0]); a[i,a[i,0]]:= tp;
      inc(a[tp,0]); a[tp,a[tp,0]]:= i;
    end;
    if xx[i]-rd[i]-2*r < -eps then begin
      inc(a[i,0]); a[i,a[i,0]]:= lf;
      inc(a[lf,0]); a[lf,a[lf,0]]:= i;
    end;
    if 1000-xx[i]-rd[i]-2*r < -eps then begin
      inc(a[i,0]); a[i,a[i,0]]:= rt;
      inc(a[rt,0]); a[rt,a[rt,0]]:= i;
    end;
  end;

  fillchar(v,sizeof(v),0);
  dfs(bt);
  if (v[lf]=1) or (v[tp]=1) then begin
    writeln('NO');
    exit;
  end;

  fillchar(v,sizeof(v),0);
  dfs(lf);
  if (v[rt]=1) then begin
    writeln('NO');
    exit;
  end;

  fillchar(v,sizeof(v),0);
  dfs(tp);
  if (v[rt]=1) then begin
    writeln('NO');
    exit;
  end;

  writeln('YES');
end.
