// Slower C++ solution:
#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];

long long dist[100005];

queue<int> que;

bool vis[100050],inq[100050];



bool spfa(int st)

{

    que.push(st);

    inq[st] = true;

    dist[st] = 0;

    long long 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] == 12345678987654321)

            {

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

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

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

                if(curmax - curmin > 1000000000)

                    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()

{

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

        dist[i] = 12345678987654321;

    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;bool l = spfa(i);

            if(!l)

            {

                printf("No\n");

                return 0;

            }

        }

    }

    printf("Yes\n");

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.8110231121232496x):
#include <bits/stdc++.h>

using namespace std;



#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)

#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)



mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());



template <typename T>

inline void chkmax(T &x, T y) { if (x < y) x = y; }



template <typename T>

inline void chkmin(T &x, T y) { if (x > y) x = y; }



inline int read() {

  #define nc getchar()

  int x = 0;

  char c = nc;

  while (c < 48) c = nc;

  while (c > 47) x = (x << 3) + (x << 1) + (c ^ 48), c = nc;

  return x;

  #undef nc

}



const int maxn = 4e5 + 10;

bool vis[maxn];

int n, m, h[maxn], val[maxn];



struct edges {

  int nxt, to, w;

} e[maxn];



void addline(int u, int v, int w) {

  static int cnt = 1;

  e[++cnt] = edges{h[u], v, w}, h[u] = cnt;

}



bool flgans = 1;



void dfs(int u) {

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

    int v = e[i].to;

    if (vis[v]) {

      flgans &= val[v] - val[u] == e[i].w;

    } else {

      vis[v] = 1, val[v] = val[u] + e[i].w, dfs(v);

    }

  }

}



int main() {

  scanf("%d %d", &n, &m);

  rep(i, 1, m) {

    int x = read(), y = read(), w = read();

    addline(x, y, w), addline(y, x, -w);

  }

  rep(i, 1, n) {

    if (!vis[i]) vis[i] = 1, dfs(i);

    if (!flgans) return puts("No"), 0;

  }

  puts("Yes");

  return 0;

}