pos = [[] for i in range(100000)]
por = [[] for s in range(200000)]
posvis = [[1] for y in range(100000)]
qe = []
n, m = map(int, input().split())
for i in range(m):
    l, r, d = map(int, input().split())
    pos[l].append([r, d, i])
    pos[r].append([l, -d, i])
    qe.append([l, r, d])

print("Yes")