import scala.collection.mutable.ListBuffer
import scala.util.Try
object Main extends App {
  val sr = new StdinReader
  val n, m = sr.nextInt

  val lst = new ListBuffer[(Int, Int, Int)]
  (1 to m).foreach{i => 
    val l, r, d = sr.nextInt
    lst += ((l, r, d))
    lst += ((r, l, -d))
  }

  val conditions: Map[Int, List[(Int, Int, Int)]] = lst.toList.groupBy(_._1)
println("YES")
}