#include <bits/stdc++.h>

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define REV(i,j,k) for(int i=j;i>=k;i--)
#define FORR(i,j,k,l) for(int i=j;i<=k;i+=l)
#define inf         freopen("in.txt", "r", stdin)
#define outf        freopen("out.txt", "w", stdout)
#define pf          printf
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c)    scanf("%d %d %d", &a, &b, &c)
#define clean(mat,n)   FOR(i,0,n) mat[i].clear()
#define minn          (long long)-1000000000000000000
#define maxx          (long long) 1000000000000000000
#define mod          1000000007
#define M_PI           3.14159265358979323846  /* pi */
#define LL           long long
#define NL '\n'
#define cnd tree[idx]
#define lnd (idx<<1)
#define rnd ((idx<<1)+1)
#define PB push_back
#define F first
#define S second
#define MAX 1000010
#define MP make_pair
#define valid(nx,ny)  ((nx >= 0) && (nx < row) && (ny >= 0) && (ny < col))
typedef pair<int,int> pr;


int lev[MAX], dis[MAX], st[MAX], col, en[MAX], vis[MAX], in[MAX];
vector<int> mat[MAX], cost[MAX], ty[MAX];
stack<int> stk;

int dfs(int p)
{
    ///cout << p << endl;
    st[p] = col;

    int temp = 0;

    FOR(i,0,(int)mat[p].size()-1)
    {
        int x = mat[p][i];

        if(st[x] != col)
        {
            if(ty[p][i])
            {
                dis[x] = dis[p] + cost[p][i];
                temp = max(temp ,dfs(x));
            }
            else
            {
                dis[x] = dis[p] - cost[p][i];
                temp = max(temp ,dfs(x));
            }
        }
        else
        {
            int v = dis[x] - dis[p];
            if(v != cost[p][i]) return 1;
        }

    }

    en[p] = col;

    return temp;
}

int main()
{
    ios::sync_with_stdio(false);
    //inf;
    ///outf;

    int n, m, a, b, c, x, y, z;

    cin >> n >> m;

    FOR(i,0,m-1)
    {
        cin >> a >> b >> c;
        mat[a].PB(b);
        cost[a].PB(c);
        ty[a].PB(1);

        mat[b].PB(a);
        cost[b].PB(c);
        ty[b].PB(0);

    }

    col = 1;
    FOR(i,1,n)
        if(st[i] != col) stk.insert(i);

    while(!stk.empty())
    {
        int x = stk.top();
        if(st[x] != col)
        {
            //cout << x << ' ';
            col++;
            if(dfs(x)){
                cout << "No" << endl;
                return 0;
            }
        }

        stk.pop();
    }

    cout << "Yes";

    return 0;
}

