import sys
N, M = map(int, input().split())
if M == 0:
    print('Yes')
    sys.exit()
m = []
for i in range(M):
    m.append(list(map(int, input().split())))
x = [None for i in range(N)]

def which_set(l, index):
    for i, ll in enumerate(l):
        if index in ll:
            return i
    return -1

lines = [set((m[0][0]-1, m[0][1]-1))]
x[m[0][0]-1] = 0
x[m[0][1]-1] = m[0][2]
for mm in m[1:]:
    l_set = which_set(lines, mm[0]-1)
    r_set = which_set(lines, mm[1]-1)
    if r_set >= 0 and l_set >=0 and r_set == l_set:
        if x[mm[1]-1] - x[mm[0]-1] == mm[2]:
            pass
        else:
            print('No')
            sys.exit()
    elif l_set >= 0 and r_set < 0:
        lines[l_set].add(mm[1]-1)
        x[mm[1]-1] = x[mm[0]-1] + mm[2]		
    elif l_set < 0 and r_set >= 0:
        lines[r_set].add(mm[0]-1)
        x[mm[0]-1] = x[mm[1]-1] - mm[2]
    elif r_set >= 0 and l_set >=0:
        lines[r_set] = lines[r_set] | lines[l_set]
        d = x[mm[1] -1] - x[mm[0]-1]
        for i in lines[l_set]:
            x[i] = x[i] - d
        del lines[l_set]
    else:
        lines.append(set((mm[0]-1, mm[1]-1)))
        x[mm[0]-1] = 0
        x[mm[1]-1] = mm[2]

print('Yes')