import java.util.*

private fun readLineStrings(): List<String> = readLine()!!.split(" ")
private fun readLineInts(): List<Int> = readLineStrings().map { it.toInt() }

data class Person(val id: Int)

class Axis(val root: Person) {
    private val locationMap = HashMap<Person, Int>()

    init {
        locationMap.put(root, 0)
    }

    fun contains(person: Person) = locationMap.containsKey(person)

    fun containsEither(left: Person, right: Person) = contains(left) || contains(right)

    fun addPerson(left: Person, right: Person, d: Int) {
        if (!contains(left) && !contains(right)) throw IllegalArgumentException()
        if (contains(left) && contains(right) && locationMap[left]!! + d != locationMap[right]!!) throw IllegalStateException()

        if (!contains(left)) return addPerson(right, left, -d)

        locationMap.put(right, locationMap[left]!! + d)
    }

    fun link(another: Axis, thisAxisPerson: Person, anotherAxisPerson: Person, offset: Int): Axis {
        val linkCenter = locationMap[thisAxisPerson]!! + offset - another.locationMap[anotherAxisPerson]!!

        another.locationMap.forEach { entry -> locationMap.put(entry.key, entry.value + linkCenter) }

        return this
    }
}

fun add(infoTriple: Triple<Int, Int, Int>, axes: Set<Axis>): Set<Axis> {
    val D = infoTriple.third
    val L = Person(infoTriple.first)
    val R = Person(infoTriple.second)

    val containerAxes = axes.filter { it.containsEither(L, R) }

    if (containerAxes.isEmpty()) {
        val newAxis = Axis(L)
        newAxis.addPerson(L, R, D)
        return axes + newAxis
    }

    if (containerAxes.size == 1) {
        containerAxes[0].addPerson(L, R, D)
        return axes
    }

    val nonContainers = axes.filter { !it.containsEither(L, R) }
    val (axis1, axis2) = containerAxes
    return (nonContainers + if (axis1.contains(L)) {
        axis1.link(axis2, L, R, D)
    } else {
        axis1.link(axis2, R, L, -D)
    }).toSet()
}

fun main(args: Array<String>) {
    val (N, M) = readLineInts()
    var axes: Set<Axis> = HashSet()

    try {
        (1 .. M).forEach {
            val (L, R, D) = readLineInts()

            axes = add(Triple(L, R, D), axes)
        }
        println("Yes")
    } catch(e: IllegalStateException) {
        println("No")
    }
}