#
N, M = list(map(int, input().split()))
Llist = []
Rlist = []
Dlist = []
for i in range(M):
    l, r, d = input().split()
    Llist.append(l)
    Rlist.append(r)
    Dlist.append(int(d))

#
mat = {}

#
def exist(i, j):
    if j<i:
        i,j = j,i
    if not i in mat:
        return False
    if not j in mat[i]:
        return False
    return True
#
def get(i, j):
    if j<i:
        return -mat[j][i]
    else:
        return mat[i][j]

#
def add(i, j, k):
    if j<i:
        i,j = j,i
        k = -k
    if exist(i, j) or i in mat:
        mat[i][j] = k
    else:
        mat[i] = {j : k}

#
for i in range(M):
    L = Llist[i]
    R = Rlist[i]
    D = Dlist[i]

    # first check
    if exist(L, R) and get(L, R)!=D:
        print('No')
        exit()

    # add
    add(L, R, D)
    #print('add', L, R, D)

    # check
    if L in mat:
        for X in mat[L]:
            if X!=R:
                x = get(L, R) - get(L, X)
                #print('LR', get(L, R), 'LX', get(L, X), 'XR', x)
                if exist(R, X) and get(R, X)!=x:
                    print('No')
                    exit()
                else:
                    add(X, R, x)

    if R in mat:
        for X in mat[R]:
            if X!=L:
                x = get(L, R) + get(R, X)
                #print('LR', get(L, R), 'RX', get(R, X), 'LX', x)
                if exist(L, X) and get(L, X)!=x:
                    print('No')
                    exit()
                else:
                    add(L, X, x)

print('Yes')
