### BUGGY CODE ###

import sys                                                   
l1 = list(map(int, input().split()))                         
N = l1[0]                                                    
M = l1[1]                                                    
                                                             
dat = []                                                     
                                                             
per_dis = [ [] for n in range(N+1)]                          
                                                             
for n in range(M):                                           
    x = list(map(int, input().split()))                      
    dat.append(x)                                            
                                                             
def bfs(start, goal):                                        
    visited = []                                             
    unvisited = [(start, 0)]                                 
    while unvisited:                                         
        now = unvisited[0]                                   
        unvisited = unvisited[1:]                            
        for next in per_dis[now[0]]:                         
            if next[0] not in visited:                       
                if next[0] == goal:                          
                    return now[1] + next[1]                  
                unvisited.append((next[0], now[1] + next[1]))
                visited.append(next[0])                      
    return None                                              
                                                             
for x in dat:                                                
    tmp = bfs(x[0], x[1])                                    
    if None == tmp:                                          
        per_dis[x[0]].append((x[1],x[2]))                    
        per_dis[x[1]].append((x[0],-x[2]))                   
    elif  x[2] != tmp:                                       
        print("No")                                          
        break;                                               
else:                                                        
    print("Yes")                                             

### FIXED CODE ###

from collections import deque

def bfs(x, graph, people):
    if people[x] is not None:
        return
    unvisited = deque([x])
    people[x] = 0
    while unvisited:
        now = unvisited.popleft()
        for next, d in graph[now]:
            if people[next] is None:
                people[next] =  people[now] + d
                unvisited.append(next)

def main():
    N, M = list(map(int, input().split()))

    graph = [ [] for n in range(N+1)]
    people = [None] * (N+1)

    for n in range(M):
        L, R, D = list(map(int, input().split()))
        graph[L].append((R, D))
        graph[R].append((L, -D))
    for i in range(1, N+1):
        bfs(i, graph, people)

    for i in range(1, N+1):
        for j, d in graph[i]:
            if people[j] - people[i] != d:
                print("No")
                exit()
    else:
        print("Yes")


if __name__ == "__main__":
    main()