#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, cost;
  edge(int t, int c) : to(t), cost(c) {}
};
int n, m;
int l[200000], r[200000], d[200000];
vector<edge> g[100000];
int dist[100000];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = (0); i < (m); ++i) {
    cin >> l[i] >> r[i] >> d[i];
    l[i]--, r[i]--;
    g[l[i]].push_back(edge(r[i], d[i]));
    g[r[i]].push_back(edge(l[i], -d[i]));
  }
  for (int i = (0); i < (n); ++i) dist[i] = -1.1e9;
  dist[l[0]] = 0;
  queue<int> Q;
  Q.push(l[0]);
  while (!Q.empty()) {
    int v = Q.front();
    Q.pop();
    for (auto e : g[v]) {
      if (dist[e.to] != -1.1e9) {
        if (dist[e.to] == dist[v] + e.cost)
          continue;
        else {
          cout << "No" << endl;
          return 0;
        }
      } else {
        dist[e.to] = dist[v] + e.cost;
        Q.push(e.to);
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
