#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 10;
int was[N];
long long d[N];
vector<pair<int, int> > v[N];
vector<pair<int, int> > g[N];
int q[N];
int main() {
  int n, m, i, a, b, c, w = 0, e = 0;
  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[e++] = i;
      while (w != e) {
        x = q[w++];
        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[e++] = (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[e++] = (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;
}
