/*
						   _________________
					  ____/:::::::::::::::::\_____
				   __/::::::::::::::::::::::::::::\___
				 _/:::::::::::::::::::::::::::::::::::\__
			   _/::::::::::::::::::::::::::::::::::::::::\_
			  /::::::::::::::::::::::::::::::::::::::::::::\
			 |::::::::::::::::::::::::::::::::::::::::::::::\
			/::::::::::::::::::::::::::::::::::::::::::::::::\
		   |:::/.:::::::;:::::::::::::::::::::::::::::::::::::|
		  /:::/.:::::::/..:::::::::::::::::::::::::::::::::::::\
		 |:::|.::::::;/.::::::::::::::::::::::::::::::::::::::::|
		 |::/.::::::/..:::::::;;'.::::::::::::::::::::::::::::::|
		 |:|.::::/./.::::::;;/..:::::::::::::::::::::::::::::::::|
		 `:|.:::|.|.:::::;/..;;;;;;-'.:;;;-':::::::::::::::::::::|
		  \|.:::|.|.:::;/.;;/  -..::'''...:::::::::::::::::::::::|
		   \;;::|.|.::/.;/--__      |::::::::::::::::::::::::::::|
			  \;;\\::/|/ =-__ --_  /::::::::::::::::::::::::::::::
				  \\/    /|  -.   |.::::::::::::::::::::::::::::::
				 _.'    /|'   /=  ||::::::::::::::::::::::::::::::
			 _.-'      //'        ||::::::::::::::::::::::::::::::
			(          -          `|::::::::::::::::::::::::::::::
			 \                      \:::::::::::::::::::::::::::::
			  |  (c)Kolansburg      \::::::::::::::::::::::::::::
			 /                      __/:::::::::::::::::::::::::::
			 \                   __/::;::;;:::::::::::::::::::::::
			 (`                 /;;;;/::|  \::::::::::::::::::::::
			 |                 |'_,::::/ \ |::::::::::::::::::::::
			.'                _/::::::/  / /:::::::::::::::. .::::
			|                /.::;;:-'_)/_/::::::::::::::::...::::
 ----.__    |               |.::|   \___/::::::::::::::::::...::::
 :::::::`----\_____          \:::\.-'::::::::::::::::::::::...::::
 ;;;;;:::::::::::::`------     \:::::::::::::::::::::::::::...::::
	  `-------:::::::\         /:::::::::::::::::::::::::::...::::
 ___.--------'::::::::\       |::::::::::::::::::::::::::::...::::
 :::::;;;:--:::::::::::|      /::::::::::::::::::::::::::::...::::
 ----'  _,-:.:::::::::::\    |.::::::::::::::::::::::::::::...::::
	 __/.::::::::::::::::|   |.::::::::::::::::::::::::::::...::::
  __/.:::;;::::::::;/.:::|   |.::::::::::::::::::::::::::::. .::::
 /.::::;/ /.:::::;/ |.::::|   \_.:::::::::::::::::::::::::::::::::
 :::::/  /.:::::/  /.:::::|     \__.::::::::::::::::::::::::::::::
 ::::|  |.:::::/  /.:::::.|        \,::::::::::::::::::::::::::::
 ::::|  |.::::|   |.:::::/|       __/::::::::::::::::::::::::::::
 \.:::\  \.:::|   |.::::||| __.--::::::::::::::::::::::::::::::::
  \.:::\_ \.:::\   \.:::'/.::::::::::::::::::::::::::::::::::::::
   \.::::\ \.:::\   \.::::::::::::::::::::::::::::::::::::::::::
*/

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <math.h>
#include <stack>
#include <random>
#include <bitset>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>
#include <unordered_map>

using namespace std;

#define X first
#define Y second

const int MAXN = 200010, M = 1000000007;

long long n, m, l, r, d;
vector< pair<int, int> > g[MAXN];
bool used[MAXN];
int cv[MAXN];
bool f = false;

void dfs(int v, int c)
{
	cv[v] = c;
	used[v] = true;
	for (pair<int, int> i : g[v])
	{
		if (!used[i.X])
			dfs(i.X, c + i.Y);
		if (cv[i.X] != cv[v] + i.Y)
			f = true;
	}
}

int main()
{
#if _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("power.in", "r", stdin);
	//freopen("power.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> l >> r >> d;
		l--;
		r--;
		g[l].push_back({ r, d });
		g[r].push_back({ l, -d });
	}

	for (int i = 0; i < n; i++)
	{
		if (!used[i])
			dfs(i, 0);
	}
	if (f)
		cout << "No";
	else
		cout << "Yes";
	return 0;
}

Measured memory_bytes: 15360