#include <iostream>
#include <cstdio>
#include <vector>
#include <cstdlib>
#define N 100005
using namespace std;

int n, m, l[N * 2], r, d, a[N];
bool v[N];
vector<int> ve[N], vd[N];

void f(int p) {
	int i;
	for (i = 0; i < ve[p].size(); i++) {
		if (!v[ve[p][i]]) v[ve[p][i]] = 1, a[ve[p][i]] = a[p] + vd[p][i], f(ve[p][i]);
		else if (a[p] + vd[p][i] != a[ve[p][i]]) {cout << "No"; exit(0);}
	}
}

int main()
{
	int i;
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		scanf("%d %d %d", &l[i], &r, &d);
		ve[l[i]].push_back(r); vd[l[i]].push_back(d);
		ve[r].push_back(l[i]); vd[r].push_back(-d);
	}
	for (i = 0; i < m; i++) if (!v[l[i]]) v[l[i]] = 1, f(l[i]);
    cout << "Yes" << endl;
    return 0;
}