object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, M = sc.nextInt
  val LRDs = List.fill(M)(sc.nextInt, sc.nextInt, sc.nextInt)
  val g = Array.fill(N + 1)(List[(Int, Int)]())
  val v = Array.fill(N + 1)(false)
  val x = Array.fill(N + 1)(0)

  def dfs(i: Int): Boolean = {
    v(i) = true
    g(i).foreach{case (j, d) =>
      if (v(j)) {
        if (x(j) != x(i) + d)
          return false
      }
      else {
        x(j) = x(i) + d
        if (!dfs(j))
          return false
      }
    }
    true
  }

  LRDs.foreach{case (l, r, d) =>
    g(l) = (r, d) :: g(l)
    g(r) = (l, -d) :: g(r)
  }
  val ans = (1 to N).forall{i => v(i) || dfs(i)}
  println(if (ans) "Yes" else "No")
}