# https://www.leighhalliday.com/weighted-quick-union-find-algorithm-in-ruby
class UnionFind

  attr_accessor :nodes, :sizes

  def initialize(num)
    self.nodes = []
    self.sizes = []

    num.times do |n|
      self.nodes[n] = n
      self.sizes[n] = 1
    end
  end

  def root(i)
    # Loop up the chain until reaching root
    while nodes[i] != i do
      # path compression for future lookups
      nodes[i] = nodes[nodes[i]]
      i = nodes[i]
    end
    i
  end

  def union(i, j)
    rooti = root i
    rootj = root j

    # already connected
    return if rooti == rootj

    # root smaller to root of larger
    if sizes[i] < sizes[j]
      nodes[rooti] = rootj
      sizes[rootj] += sizes[rooti]
    else
      nodes[rootj] = rooti
      sizes[rooti] += sizes[rootj]
    end
  end

  def connected?(i, j)
    root(i) == root(j)
  end

end

N, M = gets.split.map &:to_i

uf = UnionFind.new(N+1)
coords = {}
lrd = $<.map{|s|
  l, r, d = s.split.map &:to_i
  uf.union(l, r)
  [l, r, d]
}.sort

puts lrd.all?{|l, r, d|
  root = uf.root(l)
  coords[root] ||= {}
  if coords[root][l] && coords[root][r]
    coords[root][r] - coords[root][l] == d
  else
    if coords[root][l]
      coords[root][r] = coords[root][l] + d
    elsif coords[root][r]
      coords[root][l] = coords[root][r] - d
    else
      coords[root][l] = 0
      coords[root][r] = d
    end
    true
  end
} ? :Yes : :No
