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

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

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

  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 dfsStack(graph:Array[mu.ListBuffer[Edge]], node:Node):Unit = {
    value(node) = 0
    val stack = mu.Stack.empty[Node]
    stack push node
    while(stack nonEmpty) {
      val v = stack.pop
      graph(v) foreach ( edge => {
        if(value(edge.node) == INF) {
          value(edge.node) = value(v) + edge.cost
          stack push edge.node
        }
      })
    }
  }

  (0 until n) foreach ( i => if(value(i) == INF) dfsStack(graph, 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)
}