module Int = struct
  type t = int
  let compare = compare
end

module IntMap = Map.Make (Int)

let () =
  let n, m = Scanf.scanf "%d %d\n" (fun n m -> n, m) in
  let es =
    let es = Array.make n [] in
    for i = 1 to m do
      Scanf.scanf "%d %d %d\n" (fun l r d ->
        es.(l - 1) <- (r - 1, d) :: es.(l - 1);
        es.(r - 1) <- (l - 1, -d) :: es.(r - 1))
    done;
    fun v -> es.(v) in
  let rec dfs m v =
    List.fold_left (fun m (u, d) ->
      if IntMap.mem u m then
        if IntMap.find v m + d = IntMap.find u m then m
        else raise Not_found
      else dfs (IntMap.add u (IntMap.find v m + d) m) u) m (es v) in
  try
    Array.init n (fun v -> v)
    |> Array.fold_left (fun m v ->
        if IntMap.mem v m then m
        else dfs (IntMap.add v 0 m) v) IntMap.empty
    |> (fun _ -> print_endline "Yes")
  with Not_found -> print_endline "No"