import numpy as np

class Solver:
    def __init__(self, N, edge):
        self.N = N
        self.edge = edge
        
    def dfs(self, i, x):
        self.x_arr[i] = x
        self.visited[i] = True

        isValid = True
        for (to, cost) in self.edge[i]:
            if self.visited[to] and self.x_arr[to] != x + cost:
                isValid = False
            elif not(self.visited[to]):
                isValid = self.dfs(to, x + cost)
            if not(isValid):
                break
        return isValid
        
    def solve(self):
        self.x_arr = np.zeros(self.N).astype(int)
        self.visited = np.zeros(self.N).astype(bool)
        
        isValid = True
        for i in range(self.N):
            if not(self.visited[i]):
                isValid = self.dfs(i, 0)
                if not(isValid):
                    break
        return isValid
    
def main():
    N, M = [int(_) for _ in input().split()]
    edge = [[] for _ in range(N)]

    for _ in range(M):
        left, right, dist = [int(_) for _ in input().split()]
        left -= 1
        right -= 1
        edge[left].append((right, dist))
        edge[right].append((left, -dist))
        
    solver = Solver(N, edge)
    if (solver.solve()):
        print("Yes")
    else:
        print("No")
        
if __name__=="__main__":
    main()