#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)
INF = 10 ** 18

N, M = map(int, raw_input().split())
E = [[] for i in range(N)]
for i in range(M):
    L, R, D = map(int, raw_input().split())
    E[L - 1].append((R - 1, D))
    E[R - 1].append((L - 1, -D))

X = [INF] * N

def func(pos, x):
    if X[pos] != INF:
        return X[pos] == x
    X[pos] = x
    ret = True
    for to, D in E[pos]:
        ret = ret and func(to, x + D)
    return ret

flag = True
for i in range(N):
    if X[i] == INF:
        flag = flag and func(i, 0)

print "Yes" if flag else "No"