require 'pp'
N,M=gets.chomp.split(' ').map{|n| n.to_i}

DEBUG = false
def dpp str
	if(DEBUG)
		pp str
	end
end

def dfs(node, dist, e, f, d)
	if(d[node])
		if(d[node] != dist)
			return -1
		end
		return 0
	end
	f[node]=true
	d[node]=dist
	nodes=e[node]
	r = 0
	0.upto(nodes.size-1){|i|
		node = nodes[i]
		r = dfs(node[0], dist+node[1], e,f,d)
		if(r==-1)
			puts "No"
			exit(0)
		end
	}
end
# edge from the node
# 0 index
E = Array.new(N){[]}
# is already arrived 
F = Array.new(N){false}
# distance from `a` root
D = Array.new(N){}

1.upto(M){
	p=gets.chomp.split(' ').map{|n| n.to_i}
	p[0]-=1
	p[1]-=1
	E[p[0]].push([p[1],p[2]])
	E[p[1]].push([p[0],-p[2]])
}
dpp E

0.upto(N-1){|i|
	dfs(i,0,E,F,D)
}
puts "Yes"
