#include <bits/stdc++.h>
using namespace std;
struct node {
  int to;
  int far;
};
vector<node> v[100000];
int x[100000];
bool done[100000];
bool dfs(int i, int now) {
  x[i] = now;
  for (auto itr : v[i]) {
    done[i] = true;
    if (!done[itr.to]) {
      if (!dfs(itr.to, now + itr.far)) {
        return false;
      }
    } else if (x[itr.to] != x[i] + itr.far) {
      return false;
    }
  }
  return true;
};
int main(void) {
  int n, m;
  bool a = true;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    v[l - 1].push_back({r - 1, d});
  }
  for (int i = 0; i < n; i++)
    if (!done[i])
      if (!dfs(i, 0)) a = 0;
  string ans = (a) ? "Yes" : "No";
  cout << ans << endl;
}
