import java.util.*

data class Edge(val from: Int, val to: Int, val delta: Long)

fun main(args: Array<String>) {
  val (n, m) = readLine()!!.split(" ").map(String::toInt)
  val graph = Array(n, { mutableListOf<Edge>() })
  repeat(m) {
    val (lRaw, rRaw, dInt) = readLine()!!.split(" ").map(String::toInt)
    val l = lRaw - 1
    val r = rRaw - 1
    val d = dInt.toLong()
    graph[l].add(Edge(l, r, d))
    graph[r].add(Edge(r, l, -d))
  }

  val values = LongArray(n)
  val visited = BooleanArray(n)

  fun dfs(s: Int): Boolean {
    val stack = Stack<Int>()
    stack.push(s)
    visited[s] = true
    while (stack.isNotEmpty()) {
      val v = stack.pop()!!
      for (e in graph[v]) {
        val u = e.to
        if (visited[u]) {
          if (values[u] != values[v] + e.delta) {
            return false
          }
        } else {
          stack.push(u)
          visited[u] = true
          values[u] = values[v] + e.delta
        }
      }
    }
    return true
  }

  var ans = true
  for (s in 0 until n) {
    if (!visited[s]) {
      if (!dfs(s)) {
        ans = false
        break
      }
    }
  }
  println(if (ans) "Yes" else "No")
}
