#include <bits/stdc++.h>
using namespace std;
struct edge {
  int from, to;
  long long cost;
};
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, l, r, d;
  cin >> n >> m;
  int distance[n][n];
  fill(distance[0], distance[n], INT_MAX);
  for (int i = 0; i < n; i++) {
    distance[i][i] = 0;
  }
  set<int> use;
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> d;
    l--;
    r--;
    for (int k : use) {
      if (distance[l][k] != INT_MAX && distance[k][r] != INT_MAX) {
        if (distance[l][k] + distance[k][r] != d) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
    distance[l][r] = d;
    distance[r][l] = -d;
    use.insert(l);
    use.insert(r);
  }
  cout << "Yes" << endl;
  return 0;
}
