fun bd090(args: Array<String>) {
    val (N, M) = args[0].split(" ").map { it.toInt() }
    val edgeList = args.drop(1).map { line -> line.split(" ").map { it.toInt() } }
    val sourceToDestCost = Array(N) { mutableListOf<Pair<Int, Int>>() }
    edgeList.forEach {
        val (source, dest, cost) = it
        sourceToDestCost[source - 1].add(Pair(dest - 1, cost))
        sourceToDestCost[dest - 1].add(Pair(source - 1, -cost))
    }
    val visited = Array(N) { false }
    var numList: Array<Long>
    val queue = mutableListOf<Int>()
    var ans = true
    while (!visited.all { it }) {
        numList = Array(N) { -1L }
        val firstIndex = visited.indexOfFirst { !it }
        queue.add(firstIndex)
        numList[firstIndex] = 1
        while (!queue.isEmpty()) {
            val source = queue.removeAt(0)
            visited[source] = true
            for (destCost in sourceToDestCost[source]) {
                val (dest, cost) = destCost
                if (numList[dest] != -1L && numList[dest] != numList[source] + cost) {
                    ans = false
                    break
                }
                numList[dest] = numList[source] + cost
                if (!visited[dest]) {
                    queue.add(dest)
                }
            }
        }
    }
    println(if (ans) "Yes" else "No")
}

fun main(args: Array<String>) {
    bd090(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}