n,m = gets.chomp.split.map(&:to_i)
pos = {}
gr = {}
id = {}
idx = 0
m.times do
p pos
  l,r,d = gets.chomp.split.map(&:to_i)
  if !pos[l] && !pos[r]
    gr[idx] = [l,r]
    id[l],id[r] = idx,idx
    idx += 1
    pos[l] = 0
    pos[r] = d
  elsif !pos[l]
    gr[id[r]].push(l)
    id[l] = id[r]
    pos[l] = pos[r] - d
  elsif !pos[r]
    gr[id[l]].push(r)
    id[r] = id[l]
    pos[r] = pos[l] + d
  else
    if d != pos[r] - pos[l]
      if id[l] != id[r]
        diff = d - pos[r] + pos[l]
        gr[id[r]].each do |k|
          pos[k] += diff
          id[k] = id[l]
        end
        gr[id[l]].concat(gr[id[r]])
      else
        printf("No\n")
        exit
      end
    end
  end
end
printf("Yes\n")