#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
long long D[101000];
int ck[101000], n, m;
vector<int>E[101000], L[101000];
void DFS(int a, long long d) {
	int i;
	ck[a] = 1;
	D[a] = d;
	for (i = 0; i < E[a].size(); i++) {
		if (!ck[E[a][i]])DFS(E[a][i], D[a] + L[a][i]);
	}
}
int main() {
	int i, a, b, c;
	scanf("%d%d", &n, &m);
	for (i = 1; i <= m; i++) {
		scanf("%d%d%d", &a, &b, &c);
		E[a].push_back(b);
		L[a].push_back(c);
		E[b].push_back(a);
		L[b].push_back(-c);
	}
	for (i = 1; i <= n; i++) {
		if (!ck[i]) {
			DFS(i, 0);
		}
	}
	for (i = 1; i <= n; i++)for (int j = 0; j < E[i].size(); j++) {
		if (D[E[i][j]] != D[i] + L[i][j]) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
}