#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define Rep(i,a,b) for (int i=(a);i<=(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rRep(i,a,b) for (int i=(a);i>=b;i--)
const int Maxn=100005;
int n,m;
vector <pair <int,int> > v[Maxn];
bool used[Maxn];
int a[Maxn];
bool dfs(int cur,int col)
{
	if (used[cur])
	{
		return a[cur]==col;
	}
	used[cur]=true;
	a[cur]=col;
	for (auto &u:v[cur])
	{
		if (!dfs(u.first,a[cur]+u.second))
		{
			return false;
		}
	}
	return true;
}
int main()
{
	cin>>n>>m;
	for (int i=0;i<m;i++)
	{
		int a,b,c;
		cin>>a>>b>>c;
		v[a].push_back(make_pair(b,c));
		v[b].push_back(make_pair(a,-c));
	}
	for (int i=1;i<=n;i++)
	{
		if (!used[i])
		{
			if (!dfs(i,0))
			{
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
	return false;
}