fun main(args: Array<String>) {
    val (n, m) = readInputLine().split(" ").map { it.toInt() }
    
    // v1 -> v2なる長さdの辺があるとき、(v1, (v2, d))
    val edges = mutableMapOf<Int, MutableList<Pair<Int, Int>>>()

    for (i in 1..m) {
        val (l, r, d) = readInputLine().split(" ").map { it.toInt() }
        
        val e1 = edges.get(l) ?: mutableListOf<Pair<Int, Int>>()
        val e2 = edges.get(r) ?: mutableListOf<Pair<Int, Int>>()
        
        e1.add(Pair(r, d))
        e2.add(Pair(l, -d))
        
        edges.put(l, e1)
        edges.put(r, e2)
    }
    
    val tested = BooleanArray(n + 1)
    val pos = IntArray(n + 1)
    
    for (i in 1..n) {
        if (tested[i]) {
            continue
        }
        if (!dfs(i, edges, tested, pos)) {
            println("No")
            return
        }
    }
    println("Yes")
}

fun readInputLine(): String {
    return readLine()!!
}

fun dfs(i: Int, edge: Map<Int, List<Pair<Int, Int>>>, tested: BooleanArray, pos: IntArray): Boolean {
    tested[i] = true
    for ((v, d) in edge.get(i) ?: emptyList()) {
        if (tested[v]) {
            if (pos[v] - pos[i] != d) {
                return false
            }
        } else {
            pos[v] = pos[i] + d
            if (!dfs(v, edge, tested, pos)) {
                return false
            }
        }
    }
    
    return true
}
