N, M = map(int,input().split())
ans = {}
for _ in range(M):
  l,r,d = map(int,input().split())
  if l not in ans:
    ans[l] = 0
    ans[r] = d
  else:
    if r in ans:
      if ans[l]+d != ans[r]:
        print('No')
        exit()
    else:
      ans[r] = ans[l]+d
print('Yes')