def main():
  for _ in range(M):
      l,r,d = map(int,input().split())
      pl = find(l)
      pr = find(r)
      if pl==pr and x[r]-x[l]!=d:
          print('No')
          exit()
      else:
          p[pr] = pl
          x[pr] = x[l]+d-x[r]

def find(i):
    if p[i]==i:
        return i
    p[i],x[i] = find(p[i]),x[i]+x[p[i]]
    return p[i]


if __name__=="__main__":
    N, M = map(int, input().split())
    p = list(range(N + 1))
    x = [0] * (N + 1)
    main()
    print('Yes')