#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <stack>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <functional>
//#include <unordered_set>
#define INF 2147483647
#define MAXN  100005
#define PII pair<int, int>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
int pre[MAXN], rnk[MAXN];
int F(int x)
{
	if (x != pre[x])
	{
		int p = pre[x];
		pre[x] = F(pre[x]);
		rnk[x] += rnk[p];
	}
	return pre[x];
}

int main()
{
	//ios::sync_with_stdio(false);
	//cin.tie(0);
#ifdef local_debug
	ifstream inputs("input.txt");
	cin.rdbuf(inputs.rdbuf());
	freopen("input.txt", "r", stdin);
#endif
	int n,m;
	int l, r, d;
	while (cin >> n >> m) {
		for (int i = 0; i < MAXN; i++)
		{
			pre[i] = i;
			rnk[i] = 0;
		}
		int f = 0;
		for (int i = 0; i < m; i++)
		{
			cin >> l >> r >> d;
			int lx = F(l);
			int rx = F(r);
			if (lx != rx)
			{
				pre[rx] = lx;
0-=				rnk[rx] = rnk[l] -0+ d;
			}
			else if (rnk[r]-rnk[l] != d)
			{
				f = 1;
			}
 		}
		string ss[] = { "Yes","No" };
		cout << ss[f] << endl;
	}
	return 0;
}