import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val Array(n, m) = in.readLine.split(" ").map(_.toInt)

  val INF = 1 << 30
  val value = Array.fill(n)(INF)
  case class Edge(node:Int, cost:Int)
  val graph = Array.fill(n)(mu.ListBuffer.empty[Edge])

  Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt))
    .foreach(e => {
      val l = e(0) - 1
      val r = e(1) - 1
      val d = e(2)
      graph(l) += new Edge(r,d)
      graph(r) += new Edge(l,-d)
    })

  def bfs(node:Int):Unit = {
    if(graph(node).nonEmpty) {
      graph(node).foreach( edge => {
        if(value(edge.node) == INF) {
          value(edge.node) = value(node) + edge.cost
          bfs(edge.node)
        }
      })
    }
  }

  (0 until n).foreach( i => {
    if(value(i) == INF) {
      value(i) = 0
      bfs(i)
    }
  })

  val valid =
    (0 until n).forall( i => {
      graph(i).forall( edge => {
        value(i) + edge.cost == value(edge.node)
      })
    })

  val ans = if(valid) "Yes" else "No"
  println(ans)
}