import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, M = in.next().toInt
  val graph: Array[List[(Int, Int)]] = Array.fill[List[(Int, Int)]](N+1)(Nil) // (node, cost)

  for(_ <- 1 to M) {
    val L, R, D = in.next().toInt

    graph(L) = (R, D) :: graph(L)
    graph(R) = (L, -D) :: graph(R)
  }


  val dp = Array.fill[Option[Long]](N+1)(None)

  var ans = true
  breakable {
    for(i <- 1 to N) {
      if(dp(i).isEmpty) {
        val q = new scala.collection.mutable.Queue[(Int, Long)] // (node, cost)
        dp(i) = Some(0)
        q.enqueue((i, 0))

        while(!q.isEmpty) {
          val (nowNode, nowCost) = q.dequeue

          for((nextNode, nextCost) <- graph(nowNode)) {
            val sumCost = nextCost + nowCost
            dp(nextNode) match {
              case None =>
                dp(nextNode) = Some(sumCost)
                q.enqueue((nextNode, sumCost))
              case Some(cost) =>
                if(cost != sumCost) {
                  ans = false
                  break
                }
            }
          }
        }
      }
    }
  }

  if(ans)
    println("Yes")
  else
    println("No")
}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}

