#include <iostream>
#include <limits>
#include <queue>

int n, m;
constexpr int MAXN = 100000;
int G[MAXN + 1][MAXN + 1];
int C[MAXN + 1];
int D[MAXN + 1];
int MAXINT = std::numeric_limits<int>::max();

bool solve() {
    std::queue<int> Q;
    for (int i = 0; i < n; i++) {
        if (C[i] == 0) {
            int r = i;
            C[r] = 1;
            D[r] = 0;
            Q.push(r);
            while (!Q.empty()) {
                r = Q.front();
                for (int j = 0; j < n; j++) {
                    if ((G[r][j] < MAXINT) && (C[j] == 1)) {
                        if ((D[r] + G[r][j]) != D[j]) {
                            return false;
                        }
                    } else if ((G[r][j] < MAXINT) && (C[j] == 0)) {
                        Q.push(j);
                        C[j] = 1;
                        D[j] = D[r] + G[r][j];
                    }
                }
                Q.pop();
            }
        }
    }
    return true;
}

int main() {
    std::cin >> n >> m;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            G[i][j] = MAXINT;
        }
    }
    for (int i = 0; i < m; i++) {
        int l, r, d;
        std::cin >> l >> r >> d;
        l -= 1;
        r -= 1;
        G[l][r] = d;
        G[r][l] = -d;
    }

    if (solve()) {
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}