N,M = map(int, input().split())
LRD = [ [int(j) for j in input().split()] for _ in range(M)]
MAP = [ [] for _ in range(N+1)]
CR  = [ [0] * (N+1) for _ in range(N+1)]

def canDFS(node, par, target):
    if len(list(filter(lambda x: x!=par, MAP[node]))) == 0:
        return float("inf")
    if target in MAP[node]:
        return CR[node][target]

    ans = float("inf")
    for ch in MAP[node]:
        if ch == par: continue
        tmp = CR[node][ch]
        tmp += canDFS(ch, node,target)
        if tmp < ans:
            ans = tmp
    return ans
        


for i in range(M):
    L,R,D = LRD[i]
    
    LtoR = canDFS(L, -1, R)
    # print("LRD:", L,R,D, LtoR)

    if LtoR == D:
        continue
    elif LtoR == float("inf"):
        MAP[L].append(R)
        MAP[R].append(L)
        
        CR[L][R] = D
        CR[R][L] = -D
        # print("\tappend")
    else:
        print("No")
        exit(0)
print("Yes")

    

    

