#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <bitset>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/wait.h>

using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define lson (rt << 1)
#define rson ((rt << 1) | 1)
#define pill pair<int, int>
#define mst(a, b)	memset(a, b, sizeof a)
#define REP(i, x, n)	for(int i = x; i <= n; ++i)
const int MOD = 1e9 + 7;
const int qq = 1e5 + 10;
const int INF = 1e9 + 10;
LL pos[qq * 2];
int n, m;
struct Node {
	LL l, r, d;
	bool operator < (const Node &tmp) {
		if (l == tmp.l)	return r < tmp.r;
		return l < tmp.r;
	}
}p[qq * 2];

int main(){
	scanf("%d%d", &n, &m);
	mst(pos, -1);
	for (int i = 1; i <= m; ++i) {
		scanf("%lld%lld%lld", &p[i].l, &p[i].r, &p[i].d);
	}
	sort(p + 1, p + 1 + m);
	bool f = true;
	for (int i = 1; i <= m; ++i) {
		if (pos[p[i].l] == -1) {
			pos[p[i].l] = 0;
		}
		if (pos[p[i].r] == -1) {
			pos[p[i].r] = pos[p[i].l] + p[i].d;
		} else {
			if (pos[p[i].r] - pos[p[i].l] != p[i].d) f = false;
		}
	}
	for (int i = 1; i <= n; ++i) {
		if (pos[i] > 1e9)	 f = false;
	}
	if (f)	puts("Yes");
	else	puts("No");
	return 0;
}