#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

/*
template <class T> class UnionFind {

  private:
    struct subset  { 
      T parent; 
      T rank;
      T diff_weight;
      T sizes;
    }; 
    std::vector<subset> subsets;

  public:
    UnionFind (T N) {
      subsets.resize(N);
      for(T i=0; i<N; i++) subsets[i] = subset( { i, 0, 0, 1 } );
    }

    T Find (T x) { 
      if (subsets[x].parent == x) return x;
      subsets[x].diff_weight += subsets[subsets[x].parent].diff_weight;
      return subsets[x].parent = Find(subsets[x].parent); 
    } 

    T weight(T x) {
      Find(x);
      return subsets[x].diff_weight;
    }

    bool Same (T x, T y) {
        return Find(x) == Find(y);
    }

    bool Union (T x, T y, T w) {
      w += weight(x); w -= weight(y);

      T xroot = Find(x); 
      T yroot = Find(y); 
      if ( xroot == yroot ) return false;

      if (subsets[xroot].rank < subsets[yroot].rank) {
        std::swap(xroot, yroot);
        w = -w;
      }
      if (subsets[xroot].rank == subsets[yroot].rank) {
        subsets[xroot].rank++; 
        subsets[xroot].sizes += subsets[yroot].sizes;
      }
      subsets[yroot].parent = xroot;
      subsets[yroot].diff_weight = w;
      subsets[xroot].sizes += subsets[yroot].sizes;
      return true;
    }

    T diff(T x, T y) {
      assert( Same(x,y) );
      return weight(y) - weight(x);
    }

    T size (T x) {
      return subsets[Find(x)].sizes;
    }
};
*/

#include <iostream>
#include <vector>
#include <string>
using namespace std;

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  ll N, M; std::cin >> N >> M;
  UnionFind<ll> uf(N);
  rep(i,M) {
    ll l,r,d; std::cin >> l >> r >> d; l--, r--;
    //if ( uf.Same(l,r) ) {
    if ( uf.issame(l,r) ) {
      if ( uf.diff(l,r) != d ) {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
    //else uf.Union(l,r,d);
    else uf.merge(l,r,d);
  }
  std::cout << "Yes" << std::endl;
  return 0;
}


Measured memory_bytes: 1920