import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,m = Is()

class Cand:
    os = 0
    d = {}
    def setOS(self, os):
        self.os += os
    def append(self,lis):
        self.d.update(lis)
    def get(self,key):
        return self.d[key]+self.os
        
cands = []
for i in range(m):
    L,R,D = Is()
    flag = True
    c = 0
#    print(L,R,D)
    for i,e in enumerate(cands):
        if L in e.d and R in e.d:
#            print(D,e.get(R)-e.get(L))
            if D != e.get(R)-e.get(L):
                print("No")
                exit()
            flag = False
            break
        elif L in e.d and not R in e.d:
            if not flag:
                cands[c].setOS(D)
            e.append({R:e.d[L]+D})
#            print(e.d)
            flag = False
            c = i
        elif R in e.d and not L in e.d:
            if not flag:
                cands[i].setOS(D)
            e.append({L:e.d[R]-D})
#            print(e.d)
            flag = False
            c = i
    if flag:
        cand = Cand()
        cand.append({L:0})
        cand.append({R:D})
        cands.append(cand)
#        print(cands[-1].d)
print("Yes")