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


ed=[-1 for i in range(n)]
f=True
for i in range(n):
  if ed[i]!=-1:
    continue
  s=[i]
  while s:
    ns=[]
    for i in s:
      for j in il[i]:
        if ed[j[0]]==-1:
          ed[j[0]]=ed[i]+j[1]
          ns.append(j[0])
        else:
          if ed[j[0]]!=ed[i]+j[1]:
            f=False
            break
    s=ns
if f:
  print("Yes")
else:
  print("No")
