import sys
sys.setrecursionlimit(100000)
N, M = map(int, input().split())


def dfs(i, pos):
    done[i] = True
    if position[i] is None or position[i] == pos:
        position[i] = pos
        for r, d in rights[i]:
            dfs(r, pos+d)
    else:
        print('No')
        sys.exit()



rights = [[] for _ in range(N)]
indeg = [0]*N
done = [False] * N
for m in range(M):
    L, R, D = map(int, input().split())
    rights[L-1].append((R-1, D))

for i in range(N):
    if not done[i]:
        position = [None] * N
        dfs(i, 0)

print('Yes')

