n, m = [int(_) for _ in input().split()]
c = []
flag = True
g = [[-1, -1] for _ in range(n)]
g_num = 0
for i in range(m):
    l, r, d = [int(_) for _ in input().split()]
    l -= 1
    r -= 1
    if g[l][0] != -1 and g[r][0] != -1 and g[l][0] == g[r][0]:
        if c[g[l][0]][g[r][1]][1] - c[g[l][0]][g[l][1]][1] != d:
            flag = False
            break
    elif g[l][0] != -1 and g[r][0] != -1:
        l_pos = c[g[l][0]][g[l][1]][1]
        r_pos = c[g[r][0]][g[r][1]][1]
        if r_pos > l_pos+d:
            for j in c[g[l][0]]:
                j[1] += r_pos - d - l_pos
            c[g[r][0]].extend(c[g[l][0]])
            g[l][0] = g[r][0]
            for j in c[g[r][0]]:
                g[j[0]][1] += g[c[g[l][0]][-1][0]][1] + 1
        else:
            for j in c[g[r][0]]:
                j[1] += l_pos + d - r_pos
            c[g[l][0]].extend(c[g[r][0]])
            g[r][0] = g[l][0]
            for j in c[g[l][0]]:
                g[j[0]][1] += g[c[g[r][0]][-1][0]][1] + 1
    elif g[l][0] != -1:
        l_pos = c[g[l][0]][g[l][1]][1]
        c[g[l][0]].append([r, l_pos+d])
        g[r][0] = g[l][0]
        g[r][1] = g[c[g[l][0]][-2][0]][1]+1
    elif g[r][0] != -1:
        r_pos = c[g[r][0]][g[r][1]][1]
        c[g[r][0]].append([l, r_pos-d])
        g[l][0] = g[r][0]
        g[l][1] = g[c[g[r][0]][-2][0]][1]+1
    else:
        c.append([[l, 0], [r, d]])
        g[l][0] = g_num
        g[r][0] = g[l][0]
        g[l][1] = 0
        g[r][1] = 1
        g_num += 1
if flag:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n, m = [int(_) for _ in input().split()]
c = []
flag = True
g = [[-1, -1] for _ in range(n)]
g_num = 0
for i in range(m):
    l, r, d = [int(_) for _ in input().split()]
    l -= 1
    r -= 1
    if g[l][0] != -1 and g[r][0] != -1 and g[l][0] == g[r][0]:
        if c[g[l][0]][g[r][1]][1] - c[g[l][0]][g[l][1]][1] != d:
            flag = False
            break
    elif g[l][0] != -1 and g[r][0] != -1:
        l_pos = c[g[l][0]][g[l][1]][1]
        r_pos = c[g[r][0]][g[r][1]][1]
        if r_pos > l_pos+d:
            for j in c[g[l][0]]:
                j[1] += r_pos - d - l_pos
                if j[1] > 10**9:
                    flag = False
                    break
                g[j[0]][1] += g[c[g[r][0]][-1][0]][1] + 1
            c[g[r][0]].extend(c[g[l][0]])
            for j in c[g[l][0]]:
                g[j[0]][0] = g[r][0]

        else:
            for j in c[g[r][0]]:
                j[1] += l_pos + d - r_pos
                if j[1] > 10**9:
                    flag = False
                    break
                g[j[0]][1] += g[c[g[l][0]][-1][0]][1] + 1
            c[g[l][0]].extend(c[g[r][0]])
            for j in c[g[r][0]]:
                g[j[0]][0] = g[l][0]

    elif g[l][0] != -1:
        l_pos = c[g[l][0]][g[l][1]][1]
        c[g[l][0]].append([r, l_pos+d])
        g[r][0] = g[l][0]
        g[r][1] = g[c[g[l][0]][-2][0]][1]+1
    elif g[r][0] != -1:
        r_pos = c[g[r][0]][g[r][1]][1]
        c[g[r][0]].append([l, r_pos-d])
        g[l][0] = g[r][0]
        g[l][1] = g[c[g[r][0]][-2][0]][1]+1
    else:
        c.append([[l, 0], [r, d]])
        g[l][0] = g_num
        g[r][0] = g[l][0]
        g[l][1] = 0
        g[r][1] = 1
        g_num += 1
    if not flag:
        break
if flag:
    print("Yes")
else:
    print("No")