import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    d = [[-1] * N for _ in range(N)]
    for _ in range(M):
        L, R, D = map(int, input().split())
        L -= 1
        R -= 1
        d[L][R] = D
        d[R][L] = D
        for i in range(N):
            if d[L][i] != -1 and d[i][R] != -1:
                if d[L][R] != d[L][i] + d[i][R]:
                    print('No')
                    exit()
    
    print('Yes')

if __name__ == "__main__":
    main()