#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <bitset>
#include <sstream>
#include <cstdlib>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <climits>
#include <ctype.h>
using namespace std;

#define PI acos(-1.0)
#define EPS 1e-8
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define fi first
#define se second

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

template <class L, class R> ostream &operator <<(ostream &os, pair<L, R> P){
    return os << "(" << P.fi << "," << P.se << ")";
}
template <class T> ostream &operator <<(ostream &os, vector<T> V){
    os << "["; for (auto vv: V) os << vv << ","; return os << "]";
}

struct Matrix {
    vvi data;
    int r, c;
    Matrix(int row, int col, bool identity = false) : r(row), c(col) {
        data.assign(row, vector<int>(col, 0));
        if (identity) {
            for (int i = 0; i < r; ++i) {
                data[i][i] = 1;
            }
        }
    }
    Matrix operator * (Matrix& other) {
        int m = r, n = c, p = other.c;
        Matrix res(m, p);
        for (int i = 0; i < m; ++i) {
            for (int j = 0; j < p; ++j) {
                for (int k = 0; k < n; ++k) {
                    res.data[i][j] += data[i][k] * other.data[k][j];
                }
            }
        }
        return res;
    }
};

// 扩展欧几里得算法 res[1] * a + res[2] * b = res[0] = gcd(a, b)
vector<int> extendGcd(int a, int b) {
    if (b == 0) {
        return {a, 1, 0};
    } else {
        vector<int> tmp = extendGcd(b, a % b);
        return {tmp[0], tmp[2], tmp[1] - (a / b) * tmp[2]};
    }
}

// 矩阵快速幂
Matrix matrix_power(Matrix base, ll exp) {
    int n = base.r;
    Matrix res(n, n, true);
    while (exp) {
        if (exp & 1) {
            res = res * base;
        }
        base = base * base;
        exp >>= 1;
    }
    return res;
}

// 带模快速幂
template <typename T>
T power_mod(T base, int exp, int mod = MOD) {
    T res = 1;
    while (exp) {
        if (exp & 1) res = res * base % mod;
        base = base * base % mod;
        exp >>= 1;
    }
    return res;
}

// 快速幂
template <typename T>
T power(T base, int exp) {
    T res = 1;
    while (exp) {
        if (exp & 1) res *= base;
        base *= base;
        exp >>= 1;
    }
    return res;
}

// 求逆元
ll inv(ll a) {
    return power_mod(a, MOD - 2);
}

/******************************** template ********************************/
#define N 100010
#define M 200010
int n, m;
vector<pii> e[N];
bool visited[N];
int pos[N];

int pa[N];

int Find(int x) {
    if (x != pa[x]) {
        pa[x] = Find(pa[x]);
    }
    return pa[x];
}

bool Union(int a, int b) {
    int ra = Find(a), rb = Find(b);
    if (ra != rb) {
        pa[ra] = rb;
        return true;
    }
    return false;
}

unordered_set<int> record;

bool dfs(int cur, int from, int& lower, int& upper) {
    visited[cur] = true;
    for (pii next : e[cur]) {
        if (next.first == from) continue;
        if (visited[next.first]) {
            if (pos[next.first] != pos[cur] + next.second) {
                return false;
            }
        } else {
            pos[next.first] = pos[cur] + next.second;
            lower = min(lower, pos[next.first]);
            upper = max(upper, pos[next.first]);
            if (!dfs(next.first, cur, lower, upper)) return false;
        }
    }
    return true;
}

bool solveGroup(int rt) {
    int lower = 0, upper = 0;
    if (!dfs(rt, 0, lower, upper)) return false;
    if (upper - lower > (int)1e9) return false;
    return true;
}

int main() {
    cin >> n >> m;
    int l, r, d;
    for (int i = 1; i <= n; ++i) {
        pa[i] = i;
    }
    for (int i = 0; i < m; ++i) {
        scanf("%d%d%d", &l, &r, &d);
        e[l].push_back({r, d});
        e[r].push_back({l, -d});
        Union(l, r);
    }

    for (int i = 1; i <= n; ++i) {
        record.insert(Find(i));
    }

    for (int rt : record) {
        if (!solveGroup(rt)) {
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";

    return 0;
}


Measured memory_bytes: 14336