//ProblemD

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <memory>
#include <cstdio>
#include <cstring>

using namespace std;

//ProblemD

#define MAXN 100000
#define MAXM 200000
#define MAXD 1000000000

#define NOTSET 0x7FFFFFFF

class Solve {
private:
	int n, m;
	struct Edge {
		int to;
		int va;
	};
	vector<Edge> edges[MAXN];
	int dist[MAXN]{};

	bool dfs(int i, int d) {
		dist[i] = d;

		for (auto &e : edges[i]) {
			if (dist[e.to] == NOTSET) {
				return dfs(e.to, d + e.va);
			}
			else {
				if (d + e.va != dist[e.to]) {
					return true;
				}
			}
		}
		return false;
	}

	void solve() {
		cin >> n >> m;

		for (int i = 0; i < n; i++) dist[i] = NOTSET;

		for (int i = 0; i < m; i++) {
			int l, r, d;
			cin >> l >> r >> d;
			l--; r--;
			edges[l].push_back({ r, d });
			edges[r].push_back({ l, -d });
		}

		for (int i = 0; i < n; i++) {
			if (dist[i] == NOTSET) {
				if (dfs(i, 0)) {
					cout << "No" << endl;
					return;
				}
			}
		}
		cout << "Yes" << endl;
	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}
