import scala.collection.mutable.Queue

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, m = sc.nextInt()
  val lrd = List.fill(m)((sc.nextInt()-1, sc.nextInt()-1, sc.nextInt()))
  val adj = Array.fill(n)(List[(Int, Int)]())

  val uf = new UnionFind(n)
  for ((l, r, d) <- lrd) {
    adj(l) ::= (r, d)
    adj(r) ::= (l, -d)
    uf.unite(l, r)
  }

  val cs = lrd.groupBy(x => uf.root(x._1))
  val visited = Array.fill(n)(false)
  val x = Array.fill(n)(-1L)

  println(if (cs.values.forall(isOk)) "Yes" else "No")

  def isOk(edges: Seq[(Int, Int, Int)]): Boolean = {
    val s = edges.head._1
    val queue = Queue(s)
    visited(s) = true
    x(s) = 0
    while (queue.nonEmpty) {
      val u = queue.dequeue()
      for ((v, d) <- adj(u) if !visited(v)) {
        x(v) = x(u) + d
        queue.enqueue(v)
        visited(v) = true
      }
    }

    edges.forall{case (l, r, d) => x(r) - x(l) == d}
  }
}

class UnionFind(n: Int) {
  private val par = Array.tabulate(n)(identity)
  private val rank = Array.fill(n)(1)

  def root(x: Int): Int = {
    var res = x
    var children = List[Int]()
    while (par(res) != res) {
      children ::= res
      res = par(res)
    }

    for (y <- children) {
      par(y) = res
    }
    res
  }

  def unite(x: Int, y: Int): Unit = {
    val xr = root(x)
    val yr = root(y)
    if (xr != yr) {
      if (rank(xr) < rank(yr)) {
        par(xr) = yr
      } else {
        par(yr) = xr
        if (rank(xr) == rank(yr)) {
          rank(xr) += 1
        }
      }
    }
  }
}
