class WeightedUnionFind():

    def __init__(self,n):

        self.n = n

        self.parents = [i for i in range(n)]

        self.rank = [0 for _ in range(n)]

        self.weight = [0 for _ in range(n)]

    def find(self,x):

        root = x

        stack = [root]

        while self.parents[root] != root:

            root = self.parents[root]

            stack.append(root)

        while stack:

            s = stack.pop()

            self.weight[s] += self.weight[self.parents[s]]

        while self.parents[x] != root:

            parent = self.parents[x]

            self.parents[x] = root

            x = parent

        return root

    def unite(self,x,y,w):

        xroot = self.find(x)

        yroot = self.find(y)

        if xroot == yroot:

            return

        xrank = self.rank[xroot]

        yrank = self.rank[yroot]

        if xrank < yrank:

            self.parents[xroot] = yroot

            self.weight[xroot] = w-self.weight[x]+self.weight[y]

        else:

            self.parents[yroot] = xroot

            self.weight[yroot] = -w+self.weight[x]-self.weight[y]

            if xrank == yrank:

                self.rank[xroot] += 1

    def diff(self,x,y):

        return self.weight[x]-self.weight[y]



N,M = list(map(int,input().split()))

uf = WeightedUnionFind(N)



for _ in range(M):

    l,r,d = list(map(int,input().split()))

    if uf.find(l-1) == uf.find(r-1):

        if uf.diff(l-1,r-1) != d:

            print('No')

            break

    else:

        uf.unite(l-1,r-1,d)

else:

    print('Yes')
class DSUWeighted():

    def __init__(self, n):

        self.n = n

        self.par_size = [-1] * n

        self.wt = [0] * n



    def leader(self, a):

        #assert 0 <= a < self.n

        x = a

        order = [x]

        while self.par_size[x] >= 0:

            x = self.par_size[x]

            order.append(x)

        for s in order[:-1][::-1]:

            self.wt[s] += self.wt[self.par_size[s]]

            self.par_size[s] = x

        return x



    def same(self, a, b):

        #assert 0 <= a < self.n

        #assert 0 <= b < self.n

        return self.leader(a) == self.leader(b)



    def merge(self, a, b, w):

        #assert 0 <= a < self.n

        #assert 0 <= b < self.n

        x = self.leader(a)

        y = self.leader(b)

        w += self.wt[a] - self.wt[b]

        if x == y: return x

        if -self.par_size[x] < -self.par_size[y]:

            x, y = y, x

            w = -w

        self.par_size[x] += self.par_size[y]

        self.par_size[y] = x

        self.wt[y] = w

        return x



    def diff(self, x, y):

        return self.wt[y] - self.wt[x]



import sys

input = sys.stdin.buffer.readline



N, M = list(map(int, input().split()))



uf = DSUWeighted(N)



for _ in range(M):

    l, r, d = list(map(int, input().split()))

    if uf.same(l - 1, r - 1):

        if uf.diff(l - 1, r - 1) != d:

            print('No')

            break

    else:

        uf.merge(l - 1, r - 1, d)

else:

    print('Yes')
class WeightedUnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.weight = [0 for _ in range(n)]

    def find(self, x):
        root = x
        stack = [root]
        while self.parents[root] != root:
            root = self.parents[root]
            stack.append(root)
        while stack:
            s = stack.pop()
            self.weight[s] += self.weight[self.parents[s]]
        while self.parents[x] != root:
            parent = self.parents[x]
            self.parents[x] = root
            x = parent
        return root

    def unite(self, x, y, w):
        xroot = self.find(x)
        yroot = self.find(y)
        if xroot == yroot:
            return
        xrank = self.rank[xroot]
        yrank = self.rank[yroot]
        if xrank < yrank:
            self.parents[xroot] = yroot
            self.weight[xroot] = w - self.weight[x] + self.weight[y]
        else:
            self.parents[yroot] = xroot
            self.weight[yroot] = -w + self.weight[x] - self.weight[y]
            if xrank == yrank:
                self.rank[xroot] += 1

    def diff(self, x, y):
        return self.weight[x] - self.weight[y]


N, M = list(map(int, input().split()))
uf = WeightedUnionFind(N)
for _ in range(M):
    l, r, d = list(map(int, input().split()))
    if uf.find(l - 1) == uf.find(r - 1):
        if uf.diff(l - 1, r - 1) != d:
            print("No")
            break
    else:
        uf.unite(l - 1, r - 1, d)
else:
    print("Yes")

class DSUWeighted:
    def __init__(self, n):
        self.n = n
        self.par_size = [-1] * n
        self.wt = [0] * n

    def leader(self, a):
        # assert 0 <= a < self.n
        x = a
        order = [x]
        while self.par_size[x] >= 0:
            x = self.par_size[x]
            order.append(x)
        for s in order[:-1][::-1]:
            self.wt[s] += self.wt[self.par_size[s]]
            self.par_size[s] = x
        return x

    def same(self, a, b):
        # assert 0 <= a < self.n
        # assert 0 <= b < self.n
        return self.leader(a) == self.leader(b)

    def merge(self, a, b, w):
        # assert 0 <= a < self.n
        # assert 0 <= b < self.n
        x = self.leader(a)
        y = self.leader(b)
        w += self.wt[a] - self.wt[b]
        if x == y:
            return x
        if -self.par_size[x] < -self.par_size[y]:
            x, y = y, x
            w = -w
        self.par_size[x] += self.par_size[y]
        self.par_size[y] = x
        self.wt[y] = w
        return x

    def diff(self, x, y):
        return self.wt[y] - self.wt[x]


import sys

input = sys.stdin.buffer.readline
N, M = list(map(int, input().split()))
uf = DSUWeighted(N)
for _ in range(M):
    l, r, d = list(map(int, input().split()))
    if uf.same(l - 1, r - 1):
        if uf.diff(l - 1, r - 1) != d:
            print("No")
            break
    else:
        uf.merge(l - 1, r - 1, d)
else:
    print("Yes")

-class WeightedUnionFind: +class DSUWeighted: -        self.parents = [i for i in range(n)] -        self.rank = [0 for _ in range(n)] -        self.weight = [0 for _ in range(n)] +        self.par_size = [-1] * n +        self.wt = [0] * n -    def find(self, x): -        root = x -        stack = [root] -        while self.parents[root] != root: -            root = self.parents[root] -            stack.append(root) -        while stack: -            s = stack.pop() -            self.weight[s] += self.weight[self.parents[s]] -        while self.parents[x] != root: -            parent = self.parents[x] -            self.parents[x] = root -            x = parent -        return root +    def leader(self, a): +        # assert 0 <= a < self.n +        x = a +        order = [x] +        while self.par_size[x] >= 0: +            x = self.par_size[x] +            order.append(x) +        for s in order[:-1][::-1]: +            self.wt[s] += self.wt[self.par_size[s]] +            self.par_size[s] = x +        return x -    def unite(self, x, y, w): -        xroot = self.find(x) -        yroot = self.find(y) -        if xroot == yroot: -            return -        xrank = self.rank[xroot] -        yrank = self.rank[yroot] -        if xrank < yrank: -            self.parents[xroot] = yroot -            self.weight[xroot] = w - self.weight[x] + self.weight[y] -        else: -            self.parents[yroot] = xroot -            self.weight[yroot] = -w + self.weight[x] - self.weight[y] -            if xrank == yrank: -                self.rank[xroot] += 1 +    def same(self, a, b): +        # assert 0 <= a < self.n +        # assert 0 <= b < self.n +        return self.leader(a) == self.leader(b) + +    def merge(self, a, b, w): +        # assert 0 <= a < self.n +        # assert 0 <= b < self.n +        x = self.leader(a) +        y = self.leader(b) +        w += self.wt[a] - self.wt[b] +        if x == y: +            return x +        if -self.par_size[x] < -self.par_size[y]: +            x, y = y, x +            w = -w +        self.par_size[x] += self.par_size[y] +        self.par_size[y] = x +        self.wt[y] = w +        return x -        return self.weight[x] - self.weight[y] +        return self.wt[y] - self.wt[x] +import sys + +input = sys.stdin.buffer.readline -uf = WeightedUnionFind(N) +uf = DSUWeighted(N) -    if uf.find(l - 1) == uf.find(r - 1): +    if uf.same(l - 1, r - 1): -        uf.unite(l - 1, r - 1, d) +        uf.merge(l - 1, r - 1, d)