#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vll = std::vector<ll>;
using vpll = std::vector<pll>;
using vpii = std::vector<pii>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vvpii = std::vector<vpii>;
using vch = std::vector<char>;
using vvch = std::vector<vch>;
using tiii = std::tuple<int, int, int>;
const ll mod197 = 1000000007LL;
const ll INF = 10000000000LL;
const double PI11 = 3.14159265359;
const int dis[5] = {0, 1, 0, -1, 0};
const int disD[4] = {0, 1, 1, 0};
vpii graph[100010] = {};
ll memo[100010] = {};
int n, m;
int loop = 0;
ll depth(int i) {
  loop++;
  if (loop > 200010) {
    return -1;
  }
  if (memo[i] != -1) {
    return memo[i];
  }
  for (auto t : graph[i]) {
    ll res = depth(t.first);
    if (res != -1) {
      return res - t.second;
    }
  }
  return -1;
}
bool solve(int i, ll cost) {
  if (memo[i] == -1) {
    memo[i] = cost;
    for (auto t : graph[i]) {
      bool res = solve(t.first, cost + t.second);
      if (res == false) {
        return false;
      }
    }
    return true;
  } else if (memo[i] == cost) {
    return true;
  } else {
    return false;
  }
}
int main(void) {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    graph[l].push_back(pii(r, d));
  }
  fill(memo, memo + 100010, -1);
  for (int i = 0; i < n; i++) {
    loop = 0;
    ll res = depth(i);
    if (res == -1) {
      res = 100000LL * 100000LL + 10;
    }
    if (solve(i, res) == false) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
