MAX = 10**9


class UnionFindTree:
    def __init__(self, parent):
        self.__parent = parent

    @property
    def parent(self):
        return self.__parent

    def find(self, x, merge):
        root_x, info_x = self.__parent[x]
        if root_x != x:
            r, i = self.find(root_x, merge)
            self.__parent[x] = [r, merge(info_x, i)]
        return self.__parent[x]

    def merge(self, x, y, func):
        root_x, info_x = self.find(x, func)
        root_y, info_y = self.find(y, func)
        if root_x != root_y:
            self.__parent[y] = [root_x, func(info_x, info_y)]

    def cluster(self, func):
        result = {}
        for x in self.__parent.keys():
            root, info = self.find(x, func)
            if root not in result:
                result[root] = info
            elif result[root] is not info:
                result[root] = merge(result[root], info)
        return result


class MergeError(Exception):
    pass


def merge(x, y):
    sx = set(x)
    sy = set(y)
    xy = sx & sy
    diff = None
    d = x.copy()
    for key in sx & sy:
        xv = x[key]
        yv = y[key]
        if diff is None:
            diff = xv - yv
        if xv != yv + diff:
            raise MergeError()
    for key in sy - sx:
        d[key] = y[key] + diff
    return d


def main():
    n, m = map(int, input().split())
    info = []
    for _ in range(m):
        l, r, d = map(int, input().split())
        info.append([l, r, d])
    info.sort()
    min_x = None
    max_x = None
    c = UnionFindTree({i: [i, {i: 0}] for i in range(1, n+1)})
    for l, r, d in info:
        try:
            cl, xl = c.find(l, merge)
            cr, xr = c.find(r, merge)
        except MergeError:
            print('No')
            return
        if cl == cr:
            if xl[l] + d != xl[r]:
                print('No')
                return
        else:
            xl[r] = xl[l] + d
            xr[l] = xr[r] - d
            try:
                c.merge(l, r, merge)
            except MergeError:
                print('No')
                return
    try:
        c.cluster(merge)
    except MergeError:
        print('No')
        return
    print('Yes')


if __name__ == '__main__':
    main()
