				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)
}
	p "Yes"
rescue
	p "No"
end