n,m = gets.chomp.split(" ").map(&:to_i)
$p = Array.new(n,10**9+10)
$v = Array.new(n+1,true)
$adj = Array.new(n).map{Array.new}
$edge = Array.new(m)
f = 0
$p[0] = 0
$v[0] = false

m.times do |i|
  l,r,d = gets.chomp.split(" ").map(&:to_i)
  $edge[i] = [l-1,r-1,d]
  $adj[l-1] << [r-1,d]
  $adj[r-1] << [l-1,-d]
end

def dfs(stack)
  t = stack[-1]
  $adj[t].each do |v,d|
    if $v[v]
      $p[v] = $p[t]+d
      $v[v] = false
      dfs(stack.push(v))
    end
  end
end

while f < n
  dfs([f])
  for i in f..n
    if $v[i]
      $v[i] = false
      $p[i] = 0
      f = i
      break
    end
  end
end

ans = true

for i in 0..m-1
  if $p[$edge[i][1]]-$p[$edge[i][0]] != $edge[i][2]
    ans = false
    break
  end
end

puts ans ? "Yes" : "No"