#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct edge {
  int to, cost;
};
int N;
int M;
vector<edge> G[100000];
ll d[100000];
int main() {
  cin >> N >> M;
  int ans = 0;
  for (int i = 0; i < M; i++) {
    int a, b, d;
    cin >> a >> b >> d;
    edge s = {b, d};
    G[a].push_back(s);
    s = {a, d};
    G[b].push_back(s);
  }
  for (int i = 0; i < N + 1; i++) {
    for (edge elm : G[i]) {
      if (d[elm.to] == 0) {
        d[elm.to] += d[i] + elm.cost;
      } else {
        ans = 1;
      }
    }
  }
  if (ans == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}
