import numpy as np

def operation(infos):
  for i in xrange(len(infos)):
    for j in xrange(len(infos)):
      if(infos[j][0] == infos[i][1]):
        infos[i] = [infos[i][0],infos[j][1],infos[i][2]+infos[j][2]]
        print infos

def check(infos):
  for i in xrange(len(infos)):
    if(infos[i][0]==infos[i][1] and infos[i][2]!=0):
      return False
    for j in xrange(len(infos)):
      if(infos[i][0:2]==infos[j][0:2] and infos[i][2]!=infos[j][2]):
        return False
  return True
  


if __name__ == '__main__':

  # Get standard in
  n, m  = map(int, raw_input().split())
  infos = []
  for i in range(m):
    infos.append(map(int, raw_input().split()))

  print infos
  operation(infos)
  if(check(infos)):
    print 'Yes'
  else:
    print 'No'
