program kp_mars;

{$APPTYPE CONSOLE}

// Complexity O(n^2)

const
  maxn=100;
  maxr=500;
  eps=1e-9;

var
  n, r, i, j, ll, rr, bb, tt: integer;
  x, y, rd: array [1..maxn+5] of extended;
  c: array [1..maxn+5,0..maxn+5] of integer;
  v: array [1..maxn+5] of byte;

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

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

  // reading and checking input
  readln(n,r);

  assert((n>=0) and (n<=maxn) and (r>=0) and (r<=maxr));

  for i:=1 to n do begin
    readln(x[i],y[i],rd[i]);
    assert((x[i]>0) and (x[i]<1000) and (y[i]>0) and (y[i]<1000) and (rd[i]>0) and (rd[i]<1000));
  end;

  // solving
  fillchar(c,sizeof(c),0);

  // build list of mates
  for i:=1 to n-1 do
    for j:=i+1 to n do
      if sqrt(sqr(x[i]-x[j])+sqr(y[i]-y[j]))-rd[i]-rd[j]-2*r <= -eps then begin
        inc(c[i,0]); c[i,c[i,0]]:= j;
        inc(c[j,0]); c[j,c[j,0]]:= i;
      end;

  // adding 4 new "vertexes" (bottom, top, left, right)    
  ll:= n+1; rr:= n+2; bb:= n+3; tt:= n+4;
  for i:=1 to n do begin
    if y[i]-rd[i]-2*r <= -eps then begin
      inc(c[i,0]); c[i,c[i,0]]:= bb;
      inc(c[bb,0]); c[bb,c[bb,0]]:= i;
    end;
    if 1000-y[i]-rd[i]-2*r <= -eps then begin
      inc(c[i,0]); c[i,c[i,0]]:= tt;
      inc(c[tt,0]); c[tt,c[tt,0]]:= i;
    end;
    if x[i]-rd[i]-2*r <= -eps then begin
      inc(c[i,0]); c[i,c[i,0]]:= ll;
      inc(c[ll,0]); c[ll,c[ll,0]]:= i;
    end;
    if 1000-x[i]-rd[i]-2*r <= -eps then begin
      inc(c[i,0]); c[i,c[i,0]]:= rr;
      inc(c[rr,0]); c[rr,c[rr,0]]:= i;
    end;
  end;

  fillchar(v,sizeof(v),0);
  dfs(bb);
  if (v[ll]=1) or (v[tt]=1) then begin
    writeln('NO');
    exit;
  end;

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

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

  writeln('YES');
end.