#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <numeric>
#include <memory>
#include <functional>
#include <stdexcept>
#include <typeinfo>
#include <limits>
#include <complex>
#include <locale>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define lowbit(n) ((n)&(-(n)))
#define setbit(n, b) ((n)|((n)>>1<<(b)))
#define removebit(n, b) ((n)&~((n)>>1<<(b)))
#define flipbit(n, b) ((n)^((n)>>1<<(b)))
#define checkbit(n,b) (((n)>>(b))&1)
#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--)
#define repit(it,a) for (__typeof(a.begin()) it=a.begin();it!=a.end();++it)
#define X first
#define Y second
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define all(a) (a).begin(),(a).end()
#define reunique(v) v.erase(unique(all(v)),v.end())
#define prl cerr << "called: " << __LINE__ << endl
#define eaq(n,x) __typeof(x) n=x;
#define RET(p,x) return p<<x<<endl,0;
#define Error(p,x) p<<x<<endl;__builtin_abort();
#define Debug(x) cerr<<#x<<" = "<<x<<endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl
#define Debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")\n"
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl
const int inf=1e9,ninf=-1e9;
const long long infl=1e18,ninfl=-1e18;
const long long h1=239017,h2=731604233;
const long long mod=1000000007,mod2=1000000009;
const double pi=3.1415926535897932384626f;
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;
}
signed 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;
}

Measured memory_bytes: 11136