/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Gosu_Hiroo
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define TR(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define IN(c, x) ((c).find(x) != (c).end())   //O(log n)
#define IN_L(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define PLL pair<ll,ll>
#define PII pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>
#define FOR(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define REP(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define MOD(x, m) ((((x) % (m)) + (m)) % (m))
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define READ ({int t;cin >> t;t;})
#define EB emplace_back
#define fcout cout << fixed << setprecision(12)
#define fcerr cerr << fixed << setprecision(12)
#define print(x) cout << (x) << endl

#ifdef DEBUG
#define ERR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); _err(cerr,_it, args); }
#define DBG(x) cerr << #x << " is " << x << endl;
#else
#define DBG(x) {};
#define ERR(args...) {};
#endif
void _err(std::ostream& cerr,istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>
void _err(std::ostream& cerr, istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "  ";
    _err(cerr,++it, args...);
}

const double pi = 2 * acos(.0);
const int inf = 0x3f3f3f3f;
const ll mod = (ll) (1e9) + 7;
//const ll mod = (ll) 998244353 ;
const double eps = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

template <typename T>
ostream& operator << (ostream& os, const vector<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

template <typename T>
ostream& operator << (ostream& os, const set<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

template <typename T>
ostream& operator << (ostream& os, const deque<T> V) {
    for(auto v : V)os << v << " ";
    return os;
}

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; }

//#define int ll
template <class T>
struct WeightedUnionFind {
    struct Data {
        int parent = -1;
        T value = 0, delta = 0, total = 0;
    };
    vector<Data> data;

    WeightedUnionFind(int n) : data(n) {}

    void add(int u, T a) {
        data[u].value += a;
        data[root(u)].total += a;
    }

    void addSet(int u, T a) {
        data[root(u)].delta += a;
        data[root(u)].total -= data[root(u)].parent * a;
    }

    T get(int u) {
        return data[u].value + root_(u).second;
    }

    T getSet(int u) {
        return data[root(u)].total;
    }

    bool unite(int u, int v) {
        u = root(u);
        v = root(v);
        if (u == v) return false;
        if (data[u].parent > data[v].parent) swap(u, v);
        data[u].parent += data[v].parent;
        data[v].parent = u;
        data[v].delta -= data[u].delta;
        data[u].total += data[v].total;
        return true;
    }

    pair<int, T> root_(int u) {
        if (data[u].parent < 0) return {u, data[u].delta};
        auto p = root_(data[u].parent);
        p.second += data[u].delta;
        data[u].parent = p.first;
        data[u].delta = p.second - data[p.first].delta;
        return p;
    }

    int root(int u) { return root_(u).first; }

    bool same(int u, int v) {
        return root(u) == root(v);
    }

    int size(int u) {
        return -data[root(u)].parent;
    }


};
class DPeopleOnALine {
public:
    int N,M;

void solve(std::istream& cin, std::ostream& cout, std::ostream& cerr) {
    cin >> N >> M;
    WeightedUnionFind<int> wuf(101010);
    REP(m,M){
        int l,r,d;
        cin >> l >> r >> d;
        if(wuf.same(l,r) && wuf.get(r) - wuf.get(l) !=d){
            print("No");
            return;
        }
        else{
            wuf.addSet(l,wuf.get(r) - wuf.get(l) -d);
            wuf.unite(l,r);
        }
    }
    print("Yes");
}


};


#undef int
int main() {

	DPeopleOnALine solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
    std::ostringstream err;
	in.tie(0); ios::sync_with_stdio(0);
//	solver.solve(in, out);
    solver.solve(in, out,err);
	return 0;
}


Measured memory_bytes: 1792