import heapq
import sys
from collections import deque

class node_data():
    def __init__(self, to, dist):
        self.to = to
        self.dist = dist
    def __lt__(self,other):
        return (self.dist) < (other.dist)

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def prim(graph, N):
    node_queue = []
    done_list = [False] * (N + 1)
    done_list[0] = True
    first = graph.keys()[0]
    done_list[first] = True
    for nd in graph[first]:
        heapq.heappush(node_queue, nd)

    min_dist = 0
    while all(done_list) == False:
        if len(node_queue) <= 0:
            k = done_list.index(False)
            for nd in graph[k]:
                heapq.heappush(node_queue, nd)
            done_list[k] = True
        nd = heapq.heappop(node_queue)
        done_list[nd.to] = True
        min_dist += nd.dist
        if nd.to in graph:
            for  new_nd in graph[nd.to]:
                #if done_list[new_nd.to] == True:
                    heapq.heappush(node_queue, new_nd)
    return min_dist

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    graph = {}
    sum_D = 0
    for i in range(M):
        input_raw = read_func().strip().split()
        [L, R, D] = [int(input_raw[0]), int(input_raw[1]),int(input_raw[2])]
        sum_D += D
        if L in graph:
            graph[L].append(node_data(R, D))
        else:
            graph[L] = [node_data(R, D)]

    min_dist = prim(graph, N)
    if sum_D/2 + sum_D % 2 == min_dist:
        print "Yes"
    else:
        print "No"

if __name__ == '__main__':
    main()