/*input
3 3
1 2 1
2 3 1
1 3 5


*/
#include <iostream>
#include <vector>

typedef std::pair<int, int> ii;

const int ms = 100100;

std::vector<ii> edges[ms];
int pos[ms];
bool visit[ms];

bool dfs(int on, int cur = 0) {
	if(visit[on]) {
		return cur == pos[on];
	}
	pos[on] = cur;
	visit[on] = true;
	for(auto a : edges[on]) {
		if(!dfs(a.first, cur + a.second)) {
			return false;
		}
	}
	return true;
}

int main() {
	int n;
	int m;
	std::cin >> n >> m;
	for(int i = 0; i < m; i++) {
		int u, v, d;
		std::cin >> u >> v >> d;
		edges[u].push_back(ii(v, d));
		edges[v].push_back(ii(u, -d));
	}
	bool ans = true;
	for(int i = 1; i <= n; i++) {
		if(!visit[i]) {
			ans = ans && dfs(i);
		}
	}
	std::cout << (ans ? "Yes" : "No") << '\n';
}