N,M = map(int,input().split())
LRD = list(list(map(int,input().split())) for i in range(M))
#print(LRD)
d = {LRD[0][0]:0}

for i in range(M):
    if (LRD[i][0] in d) and (LRD[i][1] not in d):
          d[LRD[i][1]] = d[LRD[i][0]]+LRD[i][2]
    elif (LRD[i][0] in d) and (LRD[i][1] in d):
        if d[LRD[i][1]] != d[LRD[i][0]]+LRD[i][2]:
            print("No")
            exit()
    elif (LRD[i][0] not in d) and (LRD[i][1] in d):
        d[LRD[i][0]] = d[LRD[i][1]] - LRD[i][2]
    else:
        d[LRD[i][0]] = 0
        d[LRD[i][1]] = d[LRD[i][0]] + LRD[i][2]

print("Yes")