import numpy as np
n, m = map(int, input().split())
dic_list = []
listind = [-1]*n
maxind = 0
for i in range(m):    
    l, r, d = map(int, input().split())
    l -= 1
    r -= 1
    if listind[l] == -1 and listind[r] == -1:
        listind[l] = maxind
        listind[r] = maxind
        dic_list.append({l : 0, r : d})
        maxind +=1
    elif listind[l] == listind[r]:
        dic_tmp = dic_list[listind[l]]
        if dic_tmp[r] - dic_tmp[l] != d:
            print('No')
            exit()
    elif listind[l] != -1 and listind[r] != -1:
        dicl = dic_list[listind[l]]
        dicr = dic_list[listind[r]]
        dicl[r] = dicl[l] + d
        offset = dicl[r] = dicr[r]
        for key in dicr:
            dicl[key] = dicr[key] + offset
            listind[key] = listind[l]
    elif listind[l] == -1 and listind[r] != -1:
        dic_tmp = dic_list[listind[r]]
        dic_tmp[l] = dic_tmp[r] - d
        listind[l] = listind[r]
    elif listind[l] != -1 and listind[r] == -1:
        dic_tmp = dic_list[listind[l]]
        dic_tmp[r] = dic_tmp[l] + d
        listind[r] = listind[l]
print('Yes')