#include <iostream>
#include <cstdio>
#include <vector>
#include <cstdlib>

using namespace std;

//const int SP = 2100000000;
int n, m;
int l, r, d;
int a[100005];
int b[100005];
bool ans = true;
vector<int> vx[100005], wt[100005];

void dfs(int p, int q)
{
    if(b[p])
    {
        if(a[p] != q) printf("No"), exit(0);
        return;
    }
    b[p] = true;
    a[p] = q;
    for(int i = 0; i < vx[p].size(); i++)
    {
        dfs(vx[p][i], wt[p][i] + q);
    }
}

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 0; i < m; i++)
    {
        scanf("%d%d%d", &l, &r, &d);
        vx[l].push_back(r);
        vx[r].push_back(l);
        wt[l].push_back(d);
        wt[r].push_back(-d);
    }
    for(int i = 1; i <= n; i++)
    {
        if(!b[i]) dfs(i, 0);
    }
    printf("Yes");
    return 0;
}
