import std.stdio, std.conv, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

T RD(T = string)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T)(in string str) { return str.split.to!(T[]); }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool INSIDE(T)(T x, T b, T e) { return x >= b && x < e; }

long mod = pow(10, 9) + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

/*struct UnionFind
{
	void init(long n) { par = new long[](n); foreach (i; 0..n) par[i] = i; }
	long root(long i) { return par[i] == i ? i : (par[i] = root(par[i])); }
	bool same(long i, long j) { return root(i) == root(j); }
	void unite(long i, long j) { i = root(i); j = root(j); if (i == j) return; par[i] = j; }
	long[] par;
}*/
struct UnionFind
{
	void init(long n)
	{
		par = new long[](n); foreach (i; 0..n) par[i] = i;
		dist = new long[](n);
	}
	long root(long i)
	{
		if (par[i] == i) return i;
		else
		{
			auto d = distance(par[i]);
			par[i] = root(par[i]);
			dist[i] += d;
			return par[i];
		}
	}
	bool same(long i, long j) { return root(i) == root(j); }
	long distance(long i)
	{
		long d;
		long pos = i;
		while (par[pos] != pos)
		{
			d += dist[pos];
			pos = par[pos];
		}
		return d;
	}
	bool unite(long i, long j, long d)
	{
		auto root_i = root(i);
		auto root_j = root(j);
		auto d_i = distance(i);
		auto d_j = distance(j);
		if (root_i == root_j)
		{
			return d_i - d_j == d;
		}
		else
		{
			par[root_i] = j;
			dist[root_i] = d - d_i;
			return true;
		}
	}
	long[] par;
	long[] dist;
}

void main()
{
	auto N = RD!long;
	auto M = RD!long;
	UnionFind uf;
	uf.init(N);
	foreach (i; 0..M)
	{
		auto L = RD!long - 1;
		auto R = RD!long - 1;
		auto D = RD!long;
		auto r = uf.unite(R, L, D);
		if (!r)
		{
			writeln("No");
			return;
		}
	}

	writeln("Yes");
	stdout.flush();
}