N, M = map(int, input().split())
people_location = []
for i in range(N):
    people_location.append(0)
people_data = []
for i in range(M):
    person_data = list(map(int, input().split()))
    if person_data[0] > person_data[1]:
        tmp = person_data[0]
        person_data[0] = person_data[1]
        person_data[1] = tmp
        person_data[2] = 0 - person_data[2]
    people_data.append(person_data)
people_data.sort()
for i in range(M):
    local_tmp = people_location[people_data[i][0] - 1] + people_data[i][2]
    if people_location[people_data[i][1] - 1] == 0:
        people_location[people_data[i][1] - 1] = local_tmp
    elif people_location[people_data[i][1] - 1] != local_tmp:
        print("No")
        break
else:
    print("Yes")