package main

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

type data struct {
	l, r, d int
}

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 {
	x := make([]int, N+1)
	for i := range x {
		x[i] = -1
	}
	for _, d := range d {
		if x[d.l] != -1 && x[d.r] != -1 {
			if x[d.r]-x[d.l] != d.d {
				return "No"
			}
			continue
		}
		if x[d.l] == -1 && x[d.r] != -1 {
			x[d.l] = x[d.r] - d.d
			continue
		}
		if x[d.l] != -1 && x[d.r] == -1 {
			x[d.r] = x[d.l] + d.d
		}
		if x[d.l] == -1 && x[d.r] == -1 {
			x[d.l] = 1e+10
			x[d.r] = x[d.l] + d.d
		}
	}
	return "Yes"
}

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