#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
void dfs(vector<vector<pair<long long, long long>>> g, long long i,
         vector<long long> &visited, long long &max, long long &min,
         vector<long long> &point, bool &partial_flag) {
  visited[i] = 1;
  for (auto nv : g[i]) {
    if (point[nv.first] != INF) {
      if (point[nv.first] != point[i] + nv.second) {
        partial_flag = false;
      }
    } else {
      point[nv.first] = point[i] + nv.second;
      if (point[nv.first] < min) {
        min = point[nv.first];
      }
      if (point[nv.first] < max) {
        max = point[nv.first];
      }
      dfs(g, nv.first, visited, max, min, point, partial_flag);
    }
  }
}
int main() {
  long long n, m;
  cin >> n >> m;
  vector<vector<pair<long long, long long>>> g(n);
  for (int i = 0; i < (int)(m); i++) {
    long long l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    g[l].push_back(make_pair(r, d));
    g[r].push_back(make_pair(l, -d));
  }
  vector<long long> visited(n);
  vector<long long> point(n, INF);
  bool final_flag = true;
  for (int i = 0; i < (int)(n); i++) {
    if (!visited[i]) {
      bool partial_flag = true;
      long long max = 0;
      long long min = 0;
      dfs(g, i, visited, max, min, point, partial_flag);
      if (!partial_flag) {
        final_flag = false;
        break;
      }
      if (max - min > 1000000000) {
        final_flag = false;
        break;
      }
    }
  }
  if (final_flag) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}
