import heapq
import sys
input=sys.stdin.readline
N,M=map(int,input().split())

C=[0 for i in range(N+1)]
L=[[]for i in range(N+1)]
A=[10**12 for i in range(N+1)]
B=[]

for i in range(M):
    l,r,d=map(int,input().split())
    B.append([l,r,d])
    C[r]=1
    L[l].append([l,r,d])
for i in range(N+1):
    if C[i]==0:
        A[i]=0
for i in range(1,N+1):
    if A[i]==0:
        if len(L[i])>0:
            Q=[]
            for l,r,d in L[i]:
                Q.append([A[i]+d,r,l])
            #print(Q)
            heapq.heapify(Q)
            for j in range(10**6):
                if len(Q)==0:
                    break
                else:
                    q=Q[0]
                    if A[q[1]]>=q[0]:
                        A[q[1]]=q[0]
                        for k in L[q[1]]:
                            heapq.heappush(Q,[q[0]+k[2],k[1],k[0]])
                heapq.heappop(Q)
#print(C)
#print(A)
for i in range(M):

    if A[B[i][1]]!=A[B[i][0]]+B[i][2]:
        print("No")
        exit()
print("Yes")