#include <bits/stdc++.h>
using namespace std;
struct Graph {
  vector<vector<pair<pair<int, long long>, bool>>> edge;
  int n;
  vector<long long> d;
  vector<int> flag;
  Graph(int _n) {
    n = _n;
    edge.resize(n);
    d.assign(n, -1);
    flag.assign(n, 0);
  }
  void add(int from, int to, long long cost) {
    edge[from].push_back(make_pair(make_pair(to, cost), 0));
  }
  bool dfs(int v) {
    bool f = true;
    flag[v] = true;
    for (int i = 0; i < edge[v].size(); ++i) {
      if (edge[v][i].second) continue;
      edge[v][i].second = true;
      int w = edge[v][i].first.first;
      long long co = edge[v][i].first.second;
      if (d[w] == -1) {
        d[w] = d[v] + co;
        f = f && dfs(w);
      } else {
        if (d[w] - d[v] != co) return false;
        f = f && dfs(w);
      }
    }
    return f;
  }
};
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> l(m), r(m);
  vector<long long> d(m);
  for (int i = 0; i < m; ++i) {
    cin >> l[i] >> r[i] >> d[i];
    l[i]--;
    r[i]--;
  }
  Graph gp(n);
  for (int i = 0; i < m; ++i) {
    gp.add(l[i], r[i], d[i]);
    gp.add(r[i], l[i], -d[i]);
  }
  bool f = true;
  for (int i = 0; i < n; ++i) {
    if (gp.flag[i]) continue;
    gp.d[i] = 0;
    f = f && gp.dfs(i);
  }
  cout << (f ? "Yes" : "No") << "\n";
  return 0;
}
