from collections import deque
import sys
sys.setrecursionlimit(10**7)

N,M = map(int,input().split())
Graph =[[] for i in range(N)]
for i in range(M):
    L,R,D = map(int,input().split())
    Graph[L-1].append((R-1,D))
    Graph[R-1].append((L-1 ,-D))
visit=[False]*N
for i in range(N):
    if visit[i]==False:
        visit[i]=1
        A = deque()
        A.append(i)
        while A:
            x = A.pop()
            for y,d in Graph[x]:
                if (visit[y] != False) and (visit[y]!=d+visit[x]):
                    print('No')
                    sys.exit()
                elif (visit[y] == False):
                    A.append(y)
                    visit[y]=d+visit[x] 
    
print('Yes')