n,m=map(int,input().split())
INF=10**18
path=[[INF]*n for i in range(n)]
for i in range(m):
  u,v,c=map(int,input().split())
  path[u-1][v-1]=c
for i in range(n):
  for j in range(n):
    for k in range(n):
      if i==j or j==k or k==i:continue
      if path[i][k]!=INF and path[k][j]!=INF and path[i][j]!=INF:
        if path[i][k]+path[k][j]!=path[i][j]:
          print('No')
          exit()
print('Yes')