class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)
        self.weight = [0]*(n+1)
 
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.Find_Root(self.root[x])
            self.weight[x] += self.weight[self.root[x]]
            return self.root[x]

    def Unite(self, x, y, w):
        rx = self.Find_Root(x)
        ry = self.Find_Root(y)
        if(rx == ry):
            return 
        elif(self.rnk[rx] > self.rnk[ry]):
            self.root[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
        else:
            self.root[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
            if(self.rnk[rx] == self.rnk[ry]):
                self.rnk[ry] += 1
 
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)
 
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
    
    def Diff(self, x, y):
      if self.isSameGroup(x, y):
        return abs(self.weight[y] - self.weight[x])
      else:
        return None

def main():
  N, M = map(int, input().split())
  lrd = [list(map(int, input().split())) for _ in range(M)]
  U = UnionFind(N)
  flag = True

  for i in range(M):
    l, r, d = lrd[i]
    U.Unite(l-1, r-1, d)
  for i in range(M):
    l, r, d = lrd[i]
    if U.isSameGroup(l-1, r-1):
      if U.Diff(l-1, r-1) != d:
        print('No')
        exit()
  print('Yes')
  
    
if __name__ == "__main__":
  main()