def f(l,r)
	@c.each{|ary|
		if(ary[0] == l && ary[1] == r)
			return ary[2]
		end
	}
	nil
end

def set(l,r,d)
	if(f(l,r) && f(l,r) != d)
		raise
	else
		ary = [l,r,d]
		@c.push(ary)
	end
end

def check(l,r,d,t,h)
	if(h.include?(l))
		return
	else
		h.push(l)
	end

	# p "check stt:" + l.to_s + ".." + r.to_s + "(" + d.to_s + ")" + "  root:" + h.to_s + " sum:" + t.to_s

	@c.each{|a|
		if(a[0] == l)
			# p "next:" + a[1].to_s + "  from:" + t.to_s + " to:" + (t + a[2]).to_s
			if(a[1] == r)
				if(t + a[2] != d)
					raise
				end
				return
			else
				# 再帰
				check(a[1],r,d,t + a[2],h)
			end
		end
	}
end

n,m = gets.split.map(&:to_i)

@c = []

begin
m.times{
	l,r,d = gets.split.map(&:to_i)

	check(l,r,d,0,[])

	set(l,r,d)
	set(r,l,d * -1)
}
	puts "Yes"
rescue
	puts "No"
end
