There are N people standing on the x-axis. Let the coordinate of Person i be x_i. For every i, x_i is an integer between 0 and 10^9 (inclusive). It is possible that more than one person is standing at the same coordinate.  You will given M pieces of information regarding the positions of these people. The i-th piece of information has the form (L_i, R_i, D_i). This means that Person R_i is to the right of Person L_i by D_i units of distance, that is, x_{R_i} - x_{L_i} = D_i holds.  It turns out that some of these M pieces of information may be incorrect. Determine if there exists a set of values (x_1, x_2, ..., x_N) that is consistent with the given pieces of information.
class unionFind:
    parent = []

    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.weight = [0]*N

    def root(self, x):
        if self.parent[x] == x:
            return(x)
        else:
            self.parent[x] = self.root(self.parent[x])
            self.weight[x] = self.weight[self.parent[x]]
            return(self.parent[x])

    def same(self, x, y):
        x, y = x-1, y-1
        return(self.root(x) == self.root(y))

    def unite(self, x, y, w):
        x, y = x-1, y-1
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        else:
            self.parent[x] = y
            self.weight[x] = self.weight[y]+w
            return
    def getWeight(self,x):
      x-=1
      self.root(x)
      return(self.weight[x])
N,M=map(int,input().split())
G=unionFind(N)
LRD=[tuple(map(int,input().split())) for i in range(M)]
for l,r,d in LRD:
  if G.same(l,r):
    if G.getWeight(r)-G.getWeight(l) == d:
      continue
    else:
      print("No")
      exit(0)
  else:
    G.unite(r,l,d)

print("Yes")
class unionFind:
    parent = []

    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.weight = [0]*N

    def root(self, x):
        if self.parent[x] == x:
            return(x)
        else:
            p = self.root(self.parent[x])
            self.weight[x] += self.weight[self.parent[x]]
            self.parent[x] = p
            return(self.parent[x])

    def same(self, x, y):
        x, y = x-1, y-1
        return(self.root(x) == self.root(y))

    def unite(self, x, y, w):
        w -= self.getWeight(x)
        w += self.getWeight(y)
        x, y = x-1, y-1
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return
        else:
            self.parent[x] = y
            self.weight[x] = self.weight[y]+w
            return

    def getWeight(self, x):
        x -= 1
        self.root(x)
        return(self.weight[x])


def main():
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    G = unionFind(N)
    for i in range(M):
        L, R, D = map(int, input().split())
        if G.same(L, R):
            x = G.getWeight(L)
            y = G.getWeight(R)
            if x == y + D:
                continue
            else:
                print("No")
                exit(0)
        else:
            G.unite(L, R, D)
    print("Yes")


main()
