from collections import deque

N,M = map(int,input().split())

A = [[] for i in range(N)]

for i in range(M) :
    l,r,d = map(int,input().split())
    l -= 1
    r -= 1
    
    A[l].append([r,d])
    A[r].append([l,-d])

dist = [False for i in range(N)]

ans = "Yes"

flg = 0

for i in range(N) :
    if flg :
        break
    
    if dist[i] :
        continue
    
    dist[i] = 0
    
    q = deque([i])
    
    while q :
        now = q.pop()
        for to,d in A[now] :
            if not dist[to] :
                dist[to] = dist[now] + d
                q.append(to)
            
            elif dist[to] == dist[now] + d :
                continue
            
            else :
                ans = "No"
                flg = 1
                q = deque()
                break

print(ans)
