#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;

vector<P> g[maxn];
bool vis[maxn];
int f[maxn];

bool dfs(int u,int d) {
    if(vis[u]) return f[u] == d;
    f[u] = d;
    vis[u] = 1;
    for(auto v:g[u]) {
        if(!dfs(v.fi,d + v.se)) return false;
    }
    return true;
}

int main() {
#ifdef CX_TEST
    freopen("E:\\program--GG\\test_in.txt", "r", stdin);
#endif
    int n, m, i, j, u, v, w;
    scanf("%d%d", &n, &m);
    for(i = 0; i < m; i++) {
        scanf("%d%d%d", &u, &v, &w);
        g[u].push_back(P(v, w));
        g[v].push_back(P(u, -w));
    }
    for(i = 1; i <= n; i++) {
        if(!vis[i] && !dfs(i, 0)) return puts("No"),0;
    }
    puts("Yes");
    return 0;
}
