#include <bits/stdc++.h>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
template <ostream& out = cout, class... T>
void prints(T&&...) {}
template <ostream& out = cout, class... T>
void printe(T&&...) {}
template <ostream& out = cout, class... T>
void printw(T&&...) {}
template <ostream& out = cout, class... T>
void printew(T&&...) {}
template <ostream& out = cout, class... T>
void printb(T&&...) {}
template <ostream& out = cout, class... T>
void printd(T&&...) {}
template <ostream& out = cout, class... T>
void printde(T&&...){};
template <class T>
istream& operator>>(istream& in, vector<T>& v) {
  for (auto& e : v) {
    in >> e;
  }
  return in;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> rds(n + 1);
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    rds[l].emplace_back(r, d);
    rds[r].emplace_back(l, -d);
  }
  unordered_set<int> checked;
  bool ok = true;
  for (int i = 1; i <= n && ok; i++) {
    printd(checked);
    if (checked.count(i)) {
      continue;
    }
    queue<int> q;
    q.push(i);
    unordered_map<int, int> poss;
    while (ok && q.size()) {
      int idx = q.front();
      q.pop();
      checked.insert(idx);
      for (auto& rd : rds[idx]) {
        int pos = poss[idx];
        int i2 = rd.first;
        int p2 = pos + rd.second;
        if (!checked.count(i2)) {
          checked.insert(idx);
          q.push(i2);
        }
        if (!poss.count(i2)) {
          poss[i2] = p2;
        } else {
          if (poss[i2] != p2) {
            ok = false;
          }
        }
      }
      printd(poss);
    }
  }
  cout << (ok ? "Yes" : "No") << '\n';
}
