import java.util.Deque
import java.util.ArrayDeque
import java.util.ArrayList

fun main(args: Array<String>) {
    val sc = java.util.Scanner(System.`in`)
    val N = sc.nextInt()
    val M = sc.nextInt()
    val G = Array(N){ArrayList<Pair<Int, Int>>()}

    for (i in 0 until M) {
        val L = sc.nextInt() - 1
        val R = sc.nextInt() - 1
        val D = sc.nextInt()
        G[L].add(Pair(R, D))
        G[R].add(Pair(L, -D))
    }

    val dist = IntArray(N)
    val checked = BooleanArray(N)
    val q : Deque<Int> = ArrayDeque<Int>()

    for (i in 0 until N) {
        if (checked[i]) {
            continue
        }
        checked[i] = true
        dist[i] = 0
        q.add(i)

        while (!q.isEmpty()) {
            val pos = q.poll()
            for ((node, w) in G[pos]) {
                if (!checked[node]) {
                    checked[node] = true
                    dist[node] = dist[pos] + w
                    q.add(node)
                } else if (dist[node] != dist[pos] + w) {
                    println("No")
                    return
                }
            }
        }
    }
    println("Yes")
}
