import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    //nextLineとnextを同時に使ったら死ぬ
    val sc = new Scanner(System.in)
    val n, m = sc.nextInt()
    val uf = new UnionFindTree(n)
    for (i <- 0 until m) {
      val l, r, d = sc.nextInt()

      uf.diff(l - 1, r - 1) match {
        case Some(x) =>
          if (x != d) {
            println("No")
            debug(l, r, d, x)
            sys.exit(0)
          }
        case None => uf.unite(l - 1, r - 1, d)
      }
    }
    println("Yes")
  }

  def debug(args: Any*): Unit = {
    Console.err.println(args.mkString(" "))
  }
}

//閉路検出はrootにたいしてhasLoopを呼び出す
//root以外のSizeArrayは正確ではないから外部からアクセスできないようにする
//基本可変配列で初期化
class UnionFindTree(n: Int) {
  private val par = new Array[Int](n)
  private val hasLoops = new Array[Boolean](n)
  private val sizeArray = new Array[Long](n)
  private val weightArray = new Array[Long](n)
  init(n)

  def init(n: Int): Unit = {
    for (i <- 0 until n) {
      par(i) = i
      sizeArray(i) = 1
      hasLoops(i) = false
    }
  }

  def root(x: Int): Int = {
    if (par(x) == x) {
      x
    } else {
      //経路圧縮
      val tmp = root(par(x))
      weightArray(x) += weightArray(par(x))
      par(x) = tmp
      tmp
    }
  }

  def size(x: Int): Long = {
    sizeArray(root(x))
  }

  def hasLoop(i: Int): Boolean = {
    hasLoops(i)
  }

  def isSame(x: Int, y: Int): Boolean = {
    root(x) == root(y)
  }

  def unite(x: Int, y: Int, w: Int): Unit = {
    val (xx, yy) = (root(x), root(y))
    if (!isSame(x, y)) {
      //xxにyyをつけるとき
      if (sizeArray(xx) >= sizeArray(yy)) {
        par(yy) = xx
        sizeArray(xx) += sizeArray(yy)
        weightArray(yy) = -w - weightArray(y) + weightArray(x)
      }
      //yyにxxをつけるとき
      else {
        par(xx) = yy
        sizeArray(yy) += sizeArray(xx)
        weightArray(xx) = w + weightArray(y) - weightArray(x)
      }
    } else {
      hasLoops(xx) = true
    }

  }

  def diff(x: Int, y: Int): Option[Long] = {
    if (!isSame(x, y)) None else Option(weightArray(x) - weightArray(y))
  }

  def isParent(x: Int): Boolean = {
    par(x) == x
  }

}
