#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  { 
      int parent; 
      int rank;
      T diff_weight;
      int sizes;
    }; 
    std::vector<subset> subsets;

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

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

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

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

    bool Union (int x, int y, T w) {
      w += weight(x); w -= weight(y);
      x = Find(x);  y = Find(y); 
      if ( x == y ) return false;

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

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

    int size (int x) {
      return subsets[Find(x)].sizes;
    }
};

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);
  int N, M; std::cin >> N >> M;
  UnionFind<int> uf(N);
  unionfind<int> uf1(N);
  rep(i,M) {
    int l,r,d; std::cin >> l >> r >> d; l--, r--;
    assert( uf.Same(l,r) == uf1.issame(l,r) );
    if ( uf.Same(l,r) ) {
    //if ( uf.issame(l,r) ) {
      assert( uf.diff(l,r) == uf1.diff(l,r) );
      if ( uf.diff(l,r) != d ) {
        std::cout << "No" << std::endl;
        return 0;
      }
    }
    else {
      assert( uf.Union(l,r,d) == uf1.merge(l,r,d) );
      uf.Union(l,r,d);
      uf1.merge(l,r,d);
    }
    //else uf.merge(l,r,d);
  }
  std::cout << "Yes" << std::endl;
  return 0;
}


Measured memory_bytes: 2944