import sequtils,strutils

type
    unionfindtree[I : static[int]] = array[I,int]

proc find(U : unionfindtree; a : int, b :int): bool=
    var
        s = a
        t = b
    while s != U[s]:
        s = U[s]
    while t != U[t]:
        t = U[t]
    return s == t
    
proc union(U : var  unionfindtree; a : int ; b : int)=
    var
        s = a
        t = b
    while s != U[s]:
        s = U[s]
    while t != U[t]:
        t = U[t]
    U[t] = s
proc root(U : unionfindtree, a :int):int=
    var
        s = a
    while s != U[s]:
        s = U[s]
    return s


var
    N,M : int
    L, R, D : int
    dist : array[100001, int]
    ans = true
    ut : unionfindtree[100001]
(N, M) = stdin.readline.split.map(parseInt)

for i in 0..N:
    ut[i] = i

proc Distance(U : unionfindtree, a : int) : tuple[a,b :int] =
    var
        s = a
        r = 0
    while s != U[s]:
        r += dist[s]
        s = U[s]
    return (s, r)

for m in 1..M:
    (L, R, D) = stdin.readline.split.map(parseInt)
    var a,ar,b,br : int
    (a, ar) = ut.Distance(L)
    (b, br) = ut.Distance(R)
    
    if ut.find(L, R):
        if ar + D != br:
            ans = false
            break
    else:
        ut.union(L, R)
        dist[b] = ar + D - br
        
if ans:
    echo "Yes"
else:
    echo "No"
