require 'pp'
IS_DEBUG = true
# IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

def dfs(e,s,d,tr)
	stack = [] # stack
	# init
	d[s]=0
	tr[s]=s
	e[s].each{|v|
		nxtv = v[0]
		nxtd = v[1]
		nxtp = 0
		# for multiple edge
		if(d[nxtv].nil?)
			stack.push([nxtv,nxtp,nxtd])
		else
			return false if d[nxtv] != nxtd
		end
	}
	while(!stack.empty?)
		p stack
		curv,curp,curd = stack.pop
		d[curv]=curd
		tr[curv]=curp
		# dputs "(curv,curp,curd) = (#{curv},#{curp},#{curd})"
		e[curv].each{|v|
			nxtv = v[0]
			nxtp = curv
			nxtd = curd + v[1]
			next if nxtv == curp
			# dputs "(nxtv,nxtp,nxtd) = (#{nxtv},#{nxtp},#{nxtd})"
			if(d[nxtv].nil?)
				stack.push([nxtv,nxtp,nxtd])
			else
				return false if d[nxtv] != nxtd
			end
			}
	end
	return true
end

N,M=gets.chomp.split(' ').map{|n| n.to_i}
E = 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]])
}

d = Array.new(E.size){nil}
tr = Array.new(E.size){nil}
for i in 0..(E.size-1)
	if(d[i].nil?)
		flg = dfs(E,i,d,tr)
		if(!flg)
			puts "No"
			exit(0)
		end
	end
end
puts "Yes"
