import scala.util.Try
import scala.io.StdIn._
object Main extends App {
  val Array(n, m) = readLine.split(" ").map{_.toInt}

  val conditions: Map[Int, List[(Int, Int, Int)]] = (1 to m).map{i => 
    val Array(l, r, d) = readLine.split(" ").map{_.toInt}
    Seq((l, r, d), (r, l, -d))
  }.flatten.groupBy(_._1).mapValues{_.toList}

  val checked = Array.fill(n + 1)(Int.MaxValue)

  case class Check(index: Int, position: Int)

  // @scala.annotation.tailrec
  def check(cs: List[Check]): Unit = {
    if (cs.nonEmpty) {
      check(cs.flatMap{c =>
        if (checked(c.index) == Int.MaxValue) {
          checked(c.index) = c.position
          conditions.getOrElse(c.index, Nil).map{case (_, to, d) => Check(to, c.position + d)}
        } else if (checked(c.index) == c.position) {
          Nil
        } else {
          throw new Exception
        }
      })
    }
  }
  // println(Try{(1 to n).foreach{i => check(List(Check(i, 0)))}}.fold("No", "Yes"))
  // tle どこまで読めてるか確認。
println("Yes")
}
