#include <bits/stdc++.h>
using namespace std;
template <typename T>
void dbg(T a) {}
template <typename T, typename... Arg>
void dbg(T a, Arg... arg) {}
const int maxn = (1e6) + 7;
const int inf = (1e9) + 7;
const long long LLinf = (1e18) + 7;
const long double eps = 1e-9;
const long long mod = 1e9 + 7;
vector<pair<int, int> > wek[maxn];
bool vis[maxn];
long long odl[maxn];
bool f = 0;
void dfs(int x) {
  vis[x] = 1;
  for (auto s : wek[x]) {
    if (vis[s.first] == 0) {
      odl[s.first] = odl[x] + s.second;
      dfs(s.first);
    } else if (odl[s.first] != odl[x + s.second])
      f = 1;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  while (m--) {
    int a, b, c;
    cin >> a >> b >> c;
    wek[a].push_back({b, c});
    wek[b].push_back({a, -c});
  }
  for (int i = 1; i <= n; i++)
    if (vis[i] == 0) dfs(i);
  if (f)
    cout << "No";
  else
    cout << "Yes";
  return 0;
}
