import sys


class Node(object):
    def __init__(self):
        self.connected = []


def calc_dist(start, goal, dist_dict):
    dist = None
    visited = [start]
    queue = [(None, start)]
    while len(queue) > 0:
        frm = queue[0][0]
        to = queue[0][1]

        # 距離の調整
        if frm is None:
            dist = 0
        else:
            if (frm, to) in dist_dict:
                dist += dist_dict[(frm, to)]
            elif (to, frm) in dist_dict:
                dist -= dist_dict[(to, frm)]
            else:
                raise ValueError

        queue.remove(queue[0])
        if to == goal:
            return dist
        else:
            for n in to.connected:
                if n not in visited:
                    visited.append(n)
                    queue.append((to, n))
    return None


N, M = map(int, input().split())
nodes = [Node() for i in range(N + 1)]
D_dict = {}
id_set = set()

for i in range(M):
    L, R, D = map(int, input().split())
    if L in id_set and R in id_set:
        # 両方の数字が既出のとき，整合性チェック
        dist = calc_dist(nodes[L], nodes[R], D_dict)
        if dist is None:
            # 既存の関係でLからRに到達できないなら問題ない
            D_dict[(nodes[L], nodes[R])] = D
            nodes[L].connected.append(nodes[R])
            nodes[R].connected.append(nodes[L])
        else:
            # 既存の関係でLからRに到達できるなら整合性チェック
            if dist != D:
                print('No')
                sys.exit()

    else:
        # それ以外は問題ない
        id_set.add(L)
        id_set.add(R)
        D_dict[(nodes[L], nodes[R])] = D
        nodes[L].connected.append(nodes[R])
        nodes[R].connected.append(nodes[L])

print('Yes')
