
open Scanf
open Printf

let flip f x y = f y x

let rec range a b = if a >= b then [] else a :: range (a+1) b

let read_int () = scanf " %d" (fun x -> x)
let rec read_ints n = if n = 0 then [] else let i = read_int () in i :: read_ints (n-1)

let rec replicate n f =
  if n = 0 then []
  else let h = f () in h :: replicate (n-1) f

let solve n m graph =
  let pos = Array.make n None in
  let rec visit v p x =
    Array.fold_left (fun res (w, d) ->
      if not res then false
      else
        match pos.(w) with
        | None   -> pos.(w) <- Some (x + d); visit w v (x+d)
        | Some y -> y = x + d
    ) true graph.(v) in
  List.fold_left (fun res v ->
    if not res then false else
      match pos.(v) with
      | None -> visit v (-1) 0
      | Some _ -> true
  ) true (range 0 n)

let () =
  let [n; m] = read_ints 2 in
  let idcs = Array.make n 0 in
  let edges = replicate m (fun () ->
    let [l; r; d] = read_ints 3 in
    idcs.(l-1) <- idcs.(l-1) + 1;
    idcs.(r-1) <- idcs.(r-1) + 1;
    (l-1, r-1, d)) in
  let graph = Array.init n (fun i -> Array.make idcs.(i) (-1, -1)) in
  Array.fill idcs 0 n 0;
  flip List.iter edges (fun (l, r, d) ->
    graph.(l).(idcs.(l)) <- (r, d);
    graph.(r).(idcs.(r)) <- (l, -d);
    idcs.(l) <- idcs.(l) + 1;
    idcs.(r) <- idcs.(r) + 1;
  );
  let result = solve n m graph in
  printf "%s\n" (if result then "Yes" else "No")
