#include <stdio.h>

const int N = 131072;

int n, m;

struct edge {
	int to, weight;
};

struct node {
	edge e;
	node *next;
};

node nodes[N];
int currentCount = 0;
node *edges[N];
int p[N];
int count[N];
int distancePeople[N];

void addEdge(int from, int to, int weight) {
	edge e; e.to = to; e.weight = weight;
	//edges[from].push_back(e);
	node *nod = nodes + currentCount++;
	nod->e = e;
	nod->next = edges[from];
	edges[from] = nod;
}

int getPart(int x) {
	return p[x];
}

void init() {
	for(int i = 0; i < N; i++) {
		p[i] = i;
		count[i] = 1;
	}
}

void DFS(int x, int d, int initialDistancePeople, int part) {
	distancePeople[x] = initialDistancePeople + d;
	p[x] = part;
	count[part]++;
	for(node *p = edges[x]; p; p = p->next) {
		ed = p->e;
		if(p[ed.to] != part) {
			DFS(ed.to, ed.weight, distancePeople[x], part);
		}
	}
}

void unite(int x, int y, int d) {
	if(count[x] > count[y]) {
		DFS(y, d, distancePeople[x], getPart(x));
	} else {
		DFS(x, -d, distancePeople[y], getPart(y));
	}
	addEdge(x, y, d);
	addEdge(y, x, -d);
}

bool checkdistancePeople(int x, int y, int d) {
	//printf("%d %d\n", distancePeople[y] - distancePeople[x], d);
	return (distancePeople[y] - distancePeople[x]) == d;
}

int main() {
	init();
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++) {
		int x, y, d;
		scanf("%d%d%d", &x, &y, &d);
		if(getPart(x) != getPart(y)) {
			unite(x, y, d);
		} else {
			if(!checkdistancePeople(x, y, d)) {
				printf("No\n");
				return 0;
			}
		}
	}
	/*for(int i = 1; i <= n; i++) {
		printf("%d ", distancePeople[i]);
	}
	printf("\n");*/
	printf("Yes\n");
	return 0;
}