package main

import (
	"fmt"
	"io"
	"os"
)

type data struct {
	l, r, d int
}

type stack []int

func (s *stack) push(i int) {
	*s = append(*s, i)
}
func (s *stack) pop() int {
	r := (*s)[len(*s)-1]
	*s = (*s)[:len(*s)-1]
	return r
}
func (s stack) len() int {
	return len(s)
}

func parse(r io.Reader) (int, []data) {
	var N, M int
	fmt.Fscan(r, &N, &M)
	d := make([]data, M)
	for i := range d {
		fmt.Fscan(r, &d[i].l, &d[i].r, &d[i].d)
	}
	return N, d
}

func calc(N int, d []data) string {
	type edge struct {
		to, w int
	}
	e := make([][]edge, N+1)
	for _, d := range d {
		e[d.l] = append(e[d.l], edge{d.r, d.d})
		e[d.r] = append(e[d.r], edge{d.l, -d.d})
	}
	x := make([]int, N+1)
	checked := make([]bool, N+1)
	s := make(stack, 0, 2*N)
	for i := range x {
		s.push(i)
	}
	for s.len() > 0 {
		n := s.pop()
		if checked[n] {
			continue
		}
		checked[n] = true
		for _, e := range e[n] {
			s.push(e.to)
			if !checked[e.to] {
				x[e.to] = x[n] + e.w
			} else if x[e.to] != x[n]+e.w {
				return "No"
			}
		}
	}
	return "Yes"
}

func main() {
	fmt.Println(calc(parse(os.Stdin)))
}
