class Graph
  def initialize
    @vertices = {}
  end

  def connect( from, to, weight )
	  addVertex(from, to, weight)
	  addVertex(to, from, weight * -1)
  end

  def addVertex(from, to, weight)
	@vertices[from] = Vertex.new(from) unless @vertices[from]
	@vertices[to] = Vertex.new(to) unless @vertices[to]
	@vertices[from].connect(@vertices[to], weight)
  end
  attr :vertices
end

# 辺
class Edge
	def initialize(from, to, weight)
		@passed = false
		@from = from
		@to = to
		@weight = weight
	end
	def move
		@passed = true
	end
  attr_accessor  :from, :to, :weight, :passed
end

# 頂点
class Vertex
  def initialize( id )
    @id = id
    @edges = {}
  end
  def connect( to, weight )
	raise "vertex weight error" if @edges[to] && @edges[to] != weight
    @edges[to] = Edge.new(@id, to, weight)
  end

  def setPoint( point, fromId = nil )
	  # 自分の座標セットOR既にセットされている場合は優先
	  @point = point	  unless @point
      raise "point error id:%d before: %d  after:%d " % [@id,@point,point]  unless @point == point

	  # 繋がっている先の座標をセット
	  @edges.each{|vertex,edge|
		  if !edge.passed && edge.to.id != fromId
			  edge.passed = true
			  edge.to.setPoint( @point + edge.weight , @id )
		  end
	  }
  end

  attr :id, :edges, :point, :passed
end

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

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

	graph.connect(l, r, d)
}
# 各頂点にX軸上の位置を割り当てする
graph.vertices.each{|k,vertex|
	vertex.setPoint(vertex.point ? vertex.point : 0)
}

	puts "Yes"
rescue => e
#	puts e
	puts "No"
end

