n,m = map(int,input().split())
uf = [-1]*n
def root(x):
    if uf[x] < 0:
        return x
    uf[x] = root(uf[x])
    return uf[x]
def unite(x,y):
    rx, ry = root(x), root(y)
    if rx==ry: return False
    if rx > ry: rx, ry = ry, rx
    uf[rx] += uf[ry]
    uf[ry] = rx
    return True

edge = [[-1]*n for i in range(n)]
for i in range(m):
    l,r,d = map(int, input().split())
    edge[l-1][r-1] = d
    edge[r-1][l-1] = -d
    unite(l-1, r-1)

dist = [0]*n
visited = [False]*n
ans = True

def bfs(p, d=0):
    global ans
    if not visited[p]:
        visited[p] = True
        dist[p] = d
        for ind, j in enumerate(edge[p]):
            if j>= 0:
                bfs(ind, d+j)
    else:
        if dist[p] != d:
            ans = False

for i in range(n):
    if uf[i] >= 0:
        continue
    bfs(i, 0)
    if not ans:
        break

if ans:
    print("Yes")
else:
    print("No")