#include <bits/stdc++.h>
using namespace std;
int was[(int)1e5];
int d[(int)1e5];
vector<pair<int, int> > v[(int)1e5];
vector<pair<int, int> > g[(int)1e5];
queue<int> q;
int main() {
  int n, m, i, a, b, c;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    scanf("%d%d%d", &a, &b, &c);
    v[a - 1].push_back({b - 1, c});
    g[b - 1].push_back({a - 1, c});
  }
  int x;
  for (i = 0; i < n; i++) {
    if (!was[i]) {
      was[i] = 1;
      d[i] = 0;
      q.push(i);
      while (!q.empty()) {
        x = q.front();
        q.pop();
        for (i = 0; i < v[x].size(); i++) {
          if (!was[v[x][i].first]) {
            d[v[x][i].first] = d[x] + v[x][i].second;
            was[v[x][i].first] = 1;
            q.push(v[x][i].first);
          } else {
            if (d[v[x][i].first] != d[x] + v[x][i].second) {
              cout << "No\n";
              return 0;
            }
          }
        }
        for (i = 0; i < g[x].size(); i++) {
          if (!was[g[x][i].first]) {
            d[g[x][i].first] = d[x] - g[x][i].second;
            was[g[x][i].first] = 1;
            q.push(g[x][i].first);
          } else {
            if (d[g[x][i].first] != d[x] - g[x][i].second) {
              cout << "No\n";
              return 0;
            }
          }
        }
      }
    }
  }
  cout << "Yes\n";
  return 0;
}
