// Original C++ solution (slower):
#include <cstdio>

#include <iostream>

#include <algorithm>

#include <cstring>

#include <queue>



using namespace std;



struct edge

{

    int v,w,nxt;

}e[400050];



int head[100050],ecnt;



void adde(int u,int v,int w)

{

    e[++ecnt].v = v;

    e[ecnt].w = w;

    e[ecnt].nxt = head[u];

    head[u] = ecnt;

}



int N,M;

int l[200050],r[200050];

int d[200050];

int dist[100005];

queue<int> que;

bool vis[100050],inq[100050];



bool spfa(int st)

{

    que.push(st);

    inq[st] = true;

    dist[st] = 0;

    int curmax = 0,curmin = 0;

    while(!que.empty())

    {

        int u = que.front();

        que.pop();

        for(int i = head[u];i;i = e[i].nxt)

        {

            int v = e[i].v;

            if(dist[v] == 0x3f3f3f3f)

            {

                dist[v] = dist[u] + e[i].w;

                curmax = max(curmax,dist[v]);

                curmin = min(curmin,dist[v]);

                if(curmax - curmin > 1e9)

                    return false;

                vis[v] = 1;

                if(!inq[v])

                    que.push(v);

            }

            else if(dist[v] != dist[u] + e[i].w)

                return false;

        }

        inq[u] = false;

    }

    return true;

}



int main()

{

    memset(dist,0x3f,sizeof(dist));

    scanf("%d%d",&N,&M);

    for(int i = 1;i <= M; ++ i)

    {

        scanf("%d%d%d",&l[i],&r[i],&d[i]);

        adde(l[i],r[i],d[i]);

        adde(r[i],l[i],-d[i]);

    }

    for(int i = 1;i <= N; ++ i)

    {

        if(!vis[i])

        {

            vis[i] = 1;

            if(!spfa(i))

            {

                printf("No\n");

                return 0;

            }

        }

    }

    printf("Yes\n");

    return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <cstdio>

#include <algorithm>

#define N 400005

#define inf 0x7fffffff

using namespace std;



struct E {int next, to, dis;} e[N];

int n, m, num, flag, cnt;

int h[N], a[N], pos[N], obj[N];

bool vis[N];



int read()

{

    int x = 0; char c = getchar();

    while(c < '0' || c > '9') c = getchar();

    while(c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar();}

    return x;

}



void add(int u, int v, int w)

{

    e[++num].next = h[u];

    e[num].to = v;

    e[num].dis = w;

    h[u] = num;

}



void dfs(int x)

{

    if(flag) return;

    vis[x] = 1;

    for(int i = h[x]; i != 0; i = e[i].next)

    {

        int t = pos[x] + e[i].dis;

        if(pos[e[i].to] == inf) pos[e[i].to] = t, dfs(e[i].to);

        else if(t != pos[e[i].to]) {flag = 1; return;}

    }

}



int main()

{

    cin >> n >> m;

    for(int i = 1; i <= m; i++)

    {

        int a = read(), b = read(), c = read();

        add(a, b, c), add(b, a, -c);

        pos[a] = pos[b] = inf;

        obj[++cnt] = a, obj[++cnt] = b;

    }

    sort(obj + 1, obj + 1 + cnt);

    cnt = unique(obj + 1, obj + 1 + cnt) - obj - 1;

    for(int i = 1; i <= cnt; i++)

        if(!vis[obj[i]])

        {

            flag = 0;

            pos[obj[i]] = 0;

            dfs(obj[i]);

            if(flag) {cout << "No"; return 0;}

        }

    cout << "Yes";

    return 0;

}

// Fastest known solution for this problem: