#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)

int const N = 100000;
map<int, int> mp[N + 1];
int pa[N + 1];

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	f(i, 1, n + 1)pa[i] = i;
	f(i, 1, n + 1)mp[i][i] = 0;
	while (m--){
		int l, r, d;
		scanf("%d%d%d", &l, &r, &d);
		if (pa[l] == pa[r]) { if (mp[pa[l]][r] - mp[pa[l]][l] != d) { printf("No\n"); return 0; } }
		else {
			int pl = pa[l], pr = pa[r];
			if (mp[pl].size() > mp[pr].size())swap(pl, pr), swap(l, r), d = -d;
			int z = mp[pr][r] - d - mp[pl][l];
			for (map<int, int>::iterator it = mp[pl].begin(); it != mp[pl].end(); mp[pl].erase(it++)){
				pa[it->first] = pr;
				mp[pr][it->first] = it->second + z;
			}
		}
	}
	printf("Yes\n");
}