N, M = map(int, input().split())

right = [{} for _ in range(N)]

for m in range(M):
    L, R, D = map(int, input().split())
    right[L-1][R-1] = D

res = True

for l in range(N):
    for r, d in right[l].items():
        for s in set(right[l].keys()) & set(right[r].keys()):
            if right[l][s] != right[l][r] + right[r][s]:
                res = False

if res:
    print('Yes')
else:
    print('No')
