const
  NMAX = 500;
  eps = 0.000005;

var
  n,r,i,j: Integer;
  a: array[1..NMAX+4, 1..NMAX+4] of byte;
  xk,yk,rk: array[1..NMAX] of double;
  visited: array[1..NMAX+4] of byte;

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

begin

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

  readln(n,r);
  fillchar(a, sizeof(a), 0);
  for i:=1 to n do read(xk[i], yk[i], rk[i]);

  for i:=1 to n-1 do
    for j:=i+1 to n do
      if sqrt(sqr(xk[i]-xk[j])+sqr(yk[i]-yk[j])) - rk[i] - rk[j] + eps <= 2*r then
      begin
        a[i,j]:=1; a[j,i]:=1;
      end;

  //до сторон
  for i:=1 to n do
  begin
    if 1000-yk[i]-rk[i]+eps <= 2*r then begin a[i,n+1]:=1; a[n+1,i]:=1; end; //верх
    if yk[i]-rk[i]+eps <= 2*r then begin a[i,n+2]:=1; a[n+2,i]:=1; end; //низ
    if 1000-xk[i]-rk[i]+eps <= 2*r then begin a[i,n+3]:=1; a[n+3,i]:=1; end; //право
    if xk[i]-rk[i]+eps <= 2*r then begin a[i,n+4]:=1; a[n+4,i]:=1; end; //лево
  end;

  //проверка на наличие непрерывной преграды от верхней границы до нижней или правой
  fillchar(visited,sizeof(visited),0);
  dfs(n+1);
  if (visited[n+2]=1) or (visited[n+3]=1) then
  begin
    writeln('NO'); exit;
  end;

  //проверка на наличие непрерывной преграды от левой границы до нижней или правой
  fillchar(visited,sizeof(visited),0);
  dfs(n+4);
  if (visited[n+2]=1) or (visited[n+3]=1) then
  begin
    writeln('NO'); exit;
  end;

  writeln('YES');

end.