def solve(N, M, lrd):
    vs = {}
    def calc(l, r):
        cs = set([l])
        xs = [(l, 0)]
        while xs:
            x = xs.pop()
            if x[0] in vs:
                for y, d in vs[x[0]].items():
                    if y == r:
                        return d + x[1]
                    if y not in cs: 
                        xs.append((y, d + x[1]))
                        cs.add(y)
        return None
    for l, r, d in lrd:
        x = calc(l, r)
        if x is None:
            if l not in vs:
                vs[l] = {}
            if r not in vs:
                vs[r] = {}
            vs[l][r] = d
            vs[r][l] = -d
        elif x != d:
            return False
    return True

if __name__ == "__main__":
    N, M = [int(x) for x in input().split()]
    lrd = []
    for i in range(M):
        lrd.append([int(x) for x in input().split()])
    if solve(N, M, lrd):
        print("Yes")
    else:
        print("No")
