import scala.io.StdIn._
object Main extends App {
  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val person = Array.tabulate(n){_ ⇒ new UnionFind}
  var isNonParadoxical = true
  for (_ ← 0 until m){
    val Array(l, r, d) = readLine.trim.split(' ').map(_.toInt)
    if (person(r - 1).isCompatible(person(l - 1), d)) {
      person(r - 1).setInfo(person(l - 1), d)
    }else {
      isNonParadoxical = false
    }
  }
  println(
    if (isNonParadoxical) "Yes" else "No"
  )

  class UnionFind{
    private var parent = this
    private var size: Int = 1
    private var differ: Long = 0
    private def root: UnionFind = {
      if (parent != this){
        val newRoot = parent.root
        differ += parent.differ
        parent = newRoot
      }
      parent
    }
    private def isSameUnion(that: UnionFind): Boolean = {
      root == that.root
    }
    def isCompatible(that: UnionFind, diff: Int): Boolean = {
      root != that.root || that.differ + diff == differ
    }
    def setInfo(that: UnionFind, diff: Int): Unit = {
      if (!isSameUnion(that)){
        val thisR = root
        val thatR = that.root
        //thisR.differ + differ == thatR.differ + that.differ + diff
        if (thisR.size < thatR.size){
          thisR.differ = that.differ + diff - differ
          thisR.parent = thatR
          thatR.size += thisR.size
        }else {
          thatR.differ = thisR.differ - diff + differ
          thatR.parent = thisR
          thisR.size += thatR.size
        }
      }
    }
  }
}
