#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

vector<pii> g[100005];
int d[100005];
bool b[100005];

void dfs(int x) {
    for (pii i : g[x]) {
        if (!b[i.first]) {
            b[i.first] = 1;
            d[i.first] = d[x] + i.second;
            dfs(i.first);
        } else {
            if (d[i.first] != d[x] + i.second) {
                cout << "No";
                exit(0);
            }
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    int n, m, u, v, w;
    cin >> n >> m;
    fr(m) cin >> u >> v >> w, g[u].push_back({v, w}), g[v].push_back({u, -w});
    fr1(n) if (!b[i]) b[i] = 1, dfs(i);
    cout << "Yes";
}
