#include <bits/stdc++.h>
using namespace std;
int INF = (1LL << 30) - 1;
int MOD = 1e9 + 7;
int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<pair<int, int>, int> > V(M);
  for (int i = int(0); i < int(M); ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    if (a > b) {
      swap(a, b);
      c *= -1;
    }
    V[i] = make_pair(pair<int, int>(a, b), c);
  }
  sort(V.begin(), V.end());
  vector<long long> x(N, INF);
  for (int i = int(0); i < int(M); ++i) {
    auto p = V[i].first;
    int d = V[i].second;
    if (x[p.first] == INF) {
      x[p.first] = 0;
    }
    if (x[p.second] != INF && x[p.second] != x[p.first] + d) {
      cout << "No" << endl;
      return 0;
    }
    x[p.second] = x[p.first] + d;
  }
  cout << "Yes" << endl;
}
