#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, m;
  while (cin >> n >> m) {

    using T = struct {
      int a, b;
      lli c;
    };
    vector<T> v(m);
    each (i, v) cin >> i.a >> i.b >> i.c;
    for (int i = 0; i < m; ++i) {
      v.push_back(v[i]);
      swap(v.back().a, v.back().b);
      v.back().c *= -1;
    }
    sort(v.begin(), v.end(), [&] (auto i, auto j) { return make_pair(i.a, i.b) < make_pair(j.a, j.b); });

    bool f = true;
    
    map<int, lli> pos;
    each (x, v) {
      if (pos.count(x.a) == 0) {
        pos[x.a] = 0;
      }

      if (pos.count(x.b)) {
        f = f && (pos[x.b] == pos[x.a] + x.c);
      } else {
        pos[x.b] = pos[x.a] + x.c;
      }
    }
    cout << (f ? "Yes" : "No") << endl;
  }
  
  return 0;
}
