N, M = map(int, input().split())
LRD = sorted([list(map(int, input().split())) for i in range(M)])

people = [0] * (N+1)
for l, r, d in LRD:
    if people[l] & people[r]:
        if abs(people[r]) + abs(people[l]) != d:
            print("No")
            break
    else:
        people[l] = -d
        people[r] = d
else:
    print("Yes")


