n,m=map(int,input().split())

edge=[[]for _ in range(n)]

for _ in range(m):

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

  l-=1

  r-=1

  edge[l].append((r,d))

  edge[r].append((l,-d))

ans=[10**20]*n

inf=10**20

for i in range(n):

  if ans[i]!=inf:continue

  stack=[i]

  visited={i}

  ans[i]=0

  for node in stack:

    for mode,d in edge[node]:

      if ans[node]+d!=ans[mode]!=inf:exit(print("No")) #ans[node]+d!=ans[mode] and ans[mode]!=inf

      if mode in visited:continue

      visited.add(mode)

      stack.append(mode)

      if ans[mode]==inf:

        ans[mode]=ans[node]+d

        #if ans[node]+d!=ans[mode]:exit(print("No"))

print("Yes")





#float型を許すな

#numpyはpythonで

import sys

input = sys.stdin.readline

sys.setrecursionlimit(10**7)

from collections import Counter, deque

from collections import defaultdict

from itertools import combinations, permutations, accumulate, groupby, product

from bisect import bisect_left,bisect_right

from heapq import heapify, heappop, heappush

from math import floor, ceil,pi,factorial

from operator import itemgetter

def I(): return int(eval(input()))

def MI(): return list(map(int, input().split()))

def LI(): return list(map(int, input().split()))

def LI2(): return [int(eval(input())) for i in range(n)]

def MXI(): return [[LI()]for i in range(n)]

def SI(): return input().rstrip()

def printns(x): print(('\n'.join(x)))

def printni(x): print(('\n'.join(list(map(str,x)))))

inf = 10**17

mod = 10**9 + 7



class WeightedUnionfind():

    def __init__(self,n):

        self.par =[i for i in range(n+1)]

        self.rank =[0]*(n+1)

        self.weight =[0]*(n+1)



    def find(self,x):

        if self.par[x]==x:

            return x



        else:

            y =self.find(self.par[x])

            self.weight[x]+=self.weight[self.par[x]]

            self.par[x]=y

            return y



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

        rx=self.find(x)

        ry=self.find(y)

        if self.rank[rx]<self.rank[ry]:

            self.par[rx]=ry

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

        else:

            self.par[ry]=rx

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

            if self.rank[rx]==self.rank[ry]:

                self.rank[rx]+=1

    def same(self,x,y):

        return self.find(x)==self.find(y)



    def diff(self,x,y):

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



n,m=MI()

wuf=WeightedUnionfind(n)

for i in range(m):

    l,r,d=MI()

    #print(l,r,d,end=" ")

    #print(wuf.same(l,r))

    if wuf.same(l,r):

        #print(wuf.diff(l,r))

        if wuf.diff(l,r)!=d:

            print("No")

            sys.exit()

    else:

        wuf.union(l,r,d)

print("Yes")







    

    







    





        





    

    





    



    

            

        

        

    

    

    

    



    

    





    

    



        

        

    





    
n, m = map(int, input().split())
edge = [[] for _ in range(n)]
for _ in range(m):
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    edge[l].append((r, d))
    edge[r].append((l, -d))
ans = [10**20] * n
inf = 10**20
for i in range(n):
    if ans[i] != inf:
        continue
    stack = [i]
    visited = {i}
    ans[i] = 0
    for node in stack:
        for mode, d in edge[node]:
            if ans[node] + d != ans[mode] != inf:
                exit(print("No"))  # ans[node]+d!=ans[mode] and ans[mode]!=inf
            if mode in visited:
                continue
            visited.add(mode)
            stack.append(mode)
            if ans[mode] == inf:
                ans[mode] = ans[node] + d
                # if ans[node]+d!=ans[mode]:exit(print("No"))
print("Yes")

# float型を許すな
# numpyはpythonで
import sys

input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left, bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil, pi, factorial
from operator import itemgetter


def I():
    return int(eval(input()))


def MI():
    return list(map(int, input().split()))


def LI():
    return list(map(int, input().split()))


def LI2():
    return [int(eval(input())) for i in range(n)]


def MXI():
    return [[LI()] for i in range(n)]


def SI():
    return input().rstrip()


def printns(x):
    print(("\n".join(x)))


def printni(x):
    print(("\n".join(list(map(str, x)))))


inf = 10**17
mod = 10**9 + 7


class WeightedUnionfind:
    def __init__(self, n):
        self.par = [i for i in range(n + 1)]
        self.rank = [0] * (n + 1)
        self.weight = [0] * (n + 1)

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    def union(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

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


n, m = MI()
wuf = WeightedUnionfind(n)
for i in range(m):
    l, r, d = MI()
    # print(l,r,d,end=" ")
    # print(wuf.same(l,r))
    if wuf.same(l, r):
        # print(wuf.diff(l,r))
        if wuf.diff(l, r) != d:
            print("No")
            sys.exit()
    else:
        wuf.union(l, r, d)
print("Yes")

-n, m = map(int, input().split()) -edge = [[] for _ in range(n)] -for _ in range(m): -    l, r, d = map(int, input().split()) -    l -= 1 -    r -= 1 -    edge[l].append((r, d)) -    edge[r].append((l, -d)) -ans = [10**20] * n -inf = 10**20 -for i in range(n): -    if ans[i] != inf: -        continue -    stack = [i] -    visited = {i} -    ans[i] = 0 -    for node in stack: -        for mode, d in edge[node]: -            if ans[node] + d != ans[mode] != inf: -                exit(print("No"))  # ans[node]+d!=ans[mode] and ans[mode]!=inf -            if mode in visited: -                continue -            visited.add(mode) -            stack.append(mode) -            if ans[mode] == inf: -                ans[mode] = ans[node] + d -                # if ans[node]+d!=ans[mode]:exit(print("No")) +# float型を許すな +# numpyはpythonで +import sys + +input = sys.stdin.readline +sys.setrecursionlimit(10**7) +from collections import Counter, deque +from collections import defaultdict +from itertools import combinations, permutations, accumulate, groupby, product +from bisect import bisect_left, bisect_right +from heapq import heapify, heappop, heappush +from math import floor, ceil, pi, factorial +from operator import itemgetter + + +def I(): +    return int(eval(input())) + + +def MI(): +    return list(map(int, input().split())) + + +def LI(): +    return list(map(int, input().split())) + + +def LI2(): +    return [int(eval(input())) for i in range(n)] + + +def MXI(): +    return [[LI()] for i in range(n)] + + +def SI(): +    return input().rstrip() + + +def printns(x): +    print(("\n".join(x))) + + +def printni(x): +    print(("\n".join(list(map(str, x))))) + + +inf = 10**17 +mod = 10**9 + 7 + + +class WeightedUnionfind: +    def __init__(self, n): +        self.par = [i for i in range(n + 1)] +        self.rank = [0] * (n + 1) +        self.weight = [0] * (n + 1) + +    def find(self, x): +        if self.par[x] == x: +            return x +        else: +            y = self.find(self.par[x]) +            self.weight[x] += self.weight[self.par[x]] +            self.par[x] = y +            return y + +    def union(self, x, y, w): +        rx = self.find(x) +        ry = self.find(y) +        if self.rank[rx] < self.rank[ry]: +            self.par[rx] = ry +            self.weight[rx] = w - self.weight[x] + self.weight[y] +        else: +            self.par[ry] = rx +            self.weight[ry] = -w - self.weight[y] + self.weight[x] +            if self.rank[rx] == self.rank[ry]: +                self.rank[rx] += 1 + +    def same(self, x, y): +        return self.find(x) == self.find(y) + +    def diff(self, x, y): +        return self.weight[x] - self.weight[y] + + +n, m = MI() +wuf = WeightedUnionfind(n) +for i in range(m): +    l, r, d = MI() +    # print(l,r,d,end=" ") +    # print(wuf.same(l,r)) +    if wuf.same(l, r): +        # print(wuf.diff(l,r)) +        if wuf.diff(l, r) != d: +            print("No") +            sys.exit() +    else: +        wuf.union(l, r, d)