[n,m]=[int(i) for i in input().split()]
g=[[] for i in range(10**5+1)]
s=[]
d=[-1 for i in range(10**5+1)]
for i in range(m):
 a=[int(i) for i in input().split()]
 g[a[0]].append([a[1],a[2]])
 s.append(a[0])
s.sort()
ss="Yes"
def dfs(v):
    global ss
    for i in range(len(g[v])):
        if d[g[v][i][0]]==-1:
            d[g[v][i][0]]=d[v]+g[v][i][1]
            dfs(g[v][i][0])
        else:
            if d[g[v][i][0]]!=(d[v]+g[v][i][1]):
              ss="No"
for i in range(m):
  if d[s[i]]==-1:
     d[s[i]]=0
     dfs(s[i])
print(ss)
            
            
 