//
// Written by Fyodor Menshikov 21.02.2006
// 12:10-12:46
// Idea by Pavel Kuznetsov
//
type
   real=extended;
   circle=record
      x,y,r:real;
   end;

   procedure read_real(var r:real);
   begin
      read(r);
      r:=round(r*100000);
   end;

   procedure read_circle(var c:circle);
   begin
      read_real(c.x);
      read_real(c.y);
      read_real(c.r);
   end;

   function circles_connected(c1,c2:circle;r:integer):boolean;
   begin
      circles_connected:=sqr(c1.x-c2.x)+sqr(c1.y-c2.y)<sqr(c1.r+2*r+c2.r);
   end;

var
   connected:array[1..104,1..104]of boolean;
   visited:array[1..104]of boolean;
   n:integer;

   procedure visit(i:integer);
   var
      j:integer;
   begin
      if visited[i] then begin
         exit;
      end;
      visited[i]:=true;
      for j:=1 to n+4 do begin
         if connected[i,j] then begin
            visit(j);
         end;
      end;
   end;

var
   circles:array[1..100]of circle;
   r,i,j,ileft,iright,itop,ibottom:integer;
begin
//   assign(input,'input.txt');
   reset(input);
//   assign(output,'output.txt');
   rewrite(output);
   readln(n,r);
   assert((0<=n)and(n<=100));
   r:=r*100000;
   for i:=1 to n do begin
      read_circle(circles[i]);
   end;
   for i:=1 to n do begin
      for j:=1 to n do begin
         connected[i,j]:=circles_connected(circles[i],circles[j],r);
      end;
   end;
   ileft:=n+1;
   iright:=n+2;
   itop:=n+3;
   ibottom:=n+4;
   for i:=n+1 to n+4 do begin
      for j:=n+1 to n+4 do begin
         connected[i,j]:=false;
      end;
   end;
   for i:=1 to n do begin
      connected[i,ileft]:=circles[i].x-circles[i].r<2*r;
      connected[ileft,i]:=circles[i].x-circles[i].r<2*r;
      connected[i,iright]:=circles[i].x+circles[i].r>100000000-2*r;
      connected[iright,i]:=circles[i].x+circles[i].r>100000000-2*r;
      connected[i,ibottom]:=circles[i].y-circles[i].r<2*r;
      connected[ibottom,i]:=circles[i].y-circles[i].r<2*r;
      connected[i,itop]:=circles[i].y+circles[i].r>100000000-2*r;
      connected[itop,i]:=circles[i].y+circles[i].r>100000000-2*r;
   end;

   for i:=1 to n+4 do begin
      visited[i]:=false;
   end;
   visit(ibottom);
   if visited[ileft] or visited[itop] then begin
      writeln('NO');
      halt;
   end;

   for i:=1 to n+4 do begin
      visited[i]:=false;
   end;
   visit(ileft);
   if visited[iright] then begin
      writeln('NO');
      halt;
   end;

   for i:=1 to n+4 do begin
      visited[i]:=false;
   end;
   visit(itop);
   if visited[iright] then begin
      writeln('NO');
      halt;
   end;

   writeln('YES');
end.