def main()
  n, m = gets.split.map { |t| t.to_i }
  if m == 0
    puts "Yes"
    exit
  end
  loc_info = []
  m.times do
    loc_info.push(gets.split.map { |t| t.to_i })
  end

  # person to loc
  p2l = {}
  for t in loc_info
    if p2l[t[0]]
      p2l[t[0]].push(t)
    else
      p2l[t[0]] = [t]
    end
    if p2l[t[1]]
      p2l[t[1]].push(t)
    else
      p2l[t[1]] = [t]
    end
  end

  person = loc_info[0][0]
  loc_hash = {}
  while p2l.size > 0
    if loc_hash.empty?
      person = p2l.keys[0]
    else
      for person in loc_hash.keys
        break if p2l[person]
      end
      person = p2l.keys[0] unless person
    end
    list = p2l[person]
    p2l.delete(person)

    loc = loc_hash[person] || 0
    loc_hash[person] = loc
    for left, right, dist in list
      if left == person
        if loc_hash[right] and loc_hash[right] != loc + dist
          puts "No"
          exit
        end
        loc_hash[right] = loc + dist
      else
        if loc_hash[left] and loc_hash[left] != loc - dist
          puts "No"
          exit
        end
        loc_hash[left] = loc - dist
      end
    end
  end
  puts "Yes"
end

main if __FILE__ == $0
