#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1000000000;
constexpr int MODULO = 1000000007;
constexpr int dx[4] = {1, 0, -1, 0};
constexpr int dy[4] = {0, 1, 0, -1};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  map<int, map<int, int64_t>> V;
  for (int i = 0; i < m; i++) {
    int tl, tr, td;
    cin >> tl >> tr >> td;
    V[tl][tr] = td;
    V[tr][tl] = -td;
  }
  vector<int64_t> points(n);
  vector<bool> det(n, false);
  for (auto t : V) {
    if (det[t.first] == false) {
      points[t.first] = 0;
      det[t.first] = true;
    }
    for (auto s : t.second) {
      if (det[s.first]) {
        if (points[s.first] != points[t.first] + s.second) {
          cout << "No" << '\n';
          return 0;
        }
      } else {
        points[s.first] = points[t.first] + s.second;
        det[s.first] = true;
      }
    }
  }
  cout << "Yes\n";
}
