// Slower C++ solution:
#include <iostream>

#include <string.h>

#include <stdlib.h>

#include <stdio.h>

#include <bitset>

#include <algorithm>

#include <cstdio>

#include <time.h>

#include <queue>

#include <set>

#include <map>

#include <stack>

#include <math.h>

//#include <bits/stdc++.h>

#define ll long long

#define int64 long long

#define mem(x,y) memset(x,y,sizeof(x))

#define ull unsigned long long

#define pb push_back

#define INF 0x7f7f7f7f

#define lson l, mid, rt<<1

#define rson mid+1, r, rt<<1|1

#define pi 3.141592653589793238462

#define stdio std::ios::sync_with_stdio(false)

#define zero(x) (((x)>0?(x):-(x))<eps)



using namespace std;



inline bool nextDouble(double &num) {

    char in;

    double Dec = 0.1;

    bool IsN = false, IsD = false;

    in = getchar();

    if (in == EOF) return false;

    while (in != '-' && in != '.' && (in < '0' || in > '9'))

        in = getchar();

    if (in == '-') {

        IsN = true;

        num = 0;

    } else if (in == '.') {

        IsD = true;

        num = 0;

    } else num = in - '0';

    if (!IsD) {

        while (in = getchar(), in >= '0' && in <= '9') {

            num *= 10;

            num += in - '0';

        }

    }

    if (in != '.') {

        if (IsN) num = -num;

        return true;

    } else {

        while (in = getchar(), in >= '0' && in <= '9') {

            num += Dec * (in - '0');

            Dec *= 0.1;

        }

    }

    if (IsN) num = -num;

    return true;

}

inline bool nextLongDouble(long double &num) {

    char in;

    long double Dec = 0.1;

    bool IsN = false, IsD = false;

    in = getchar();

    if (in == EOF) return false;

    while (in != '-' && in != '.' && (in < '0' || in > '9'))

        in = getchar();

    if (in == '-') {

        IsN = true;

        num = 0;

    } else if (in == '.') {

        IsD = true;

        num = 0;

    } else num = in - '0';

    if (!IsD) {

        while (in = getchar(), in >= '0' && in <= '9') {

            num *= 10;

            num += in - '0';

        }

    }

    if (in != '.') {

        if (IsN) num = -num;

        return true;

    } else {

        while (in = getchar(), in >= '0' && in <= '9') {

            num += Dec * (in - '0');

            Dec *= 0.1;

        }

    }

    if (IsN) num = -num;

    return true;

}

inline bool nextInt(int &num) {

    char in;

    bool IsN = false;

    in = getchar();

    if (in == EOF) return false;

    while (in != '-' && (in < '0' || in > '9')) in = getchar();

    if (in == '-') {

        IsN = true;

        num = 0;

    } else num = in - '0';

    while (in = getchar(), in >= '0' && in <= '9') {

        num *= 10, num += in - '0';

    }

    if (IsN) num = -num;

    return true;

}

inline bool nextLong(ll &num) {

    char in;

    bool IsN = false;

    in = getchar();

    if (in == EOF) return false;

    while (in != '-' && (in < '0' || in > '9')) in = getchar();

    if (in == '-') {

        IsN = true;

        num = 0;

    } else num = in - '0';

    while (in = getchar(), in >= '0' && in <= '9') {

        num *= 10, num += in - '0';

    }

    if (IsN) num = -num;

    return true;

}

inline bool blank(char ch) {

    return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';

}

inline void read(char *s) {

    char ch = getchar();

    for (; blank(ch); ch = getchar());

    for (; !blank(ch); ch = getchar()) * s++ = ch;

    *s = 0;

}

const int maxn = 1e5 + 5;

const int maxm = 2e6 + 5;

const int mod =  1e9;

const int seed = 10007;

const double eps = 1e-6;

int n, m;

typedef pair<int, int> dist;



vector<dist> g[maxn];



int dis[maxn];

bool vis[maxn];

bool dfs(int x) {

    vis[x] = false;

    for (int i = 0; i < g[x].size(); i++) {

        int v = g[x][i].first;

        int w = g[x][i].second;

        if (dis[v] == -1) {

            dis[v] = dis[x] + w;

            if (!dfs(v)) return false;

        } else {

            if (dis[v] == dis[x] + w) {

                continue;

            } else {

                return false;

            }

        }

    }

    return true;

}



int main() {

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

    int u, v, w;

    for (int i = 0; i < m; i++) {

        scanf("%d%d%d", &u, &v, &w);

        g[u].pb(dist(v, w));

    }

    mem(vis, true);

    bool flag = true;

    for (int i = 1; i <= n; i++) {

        if (vis[i]) {

            mem(dis, -1);

            flag = dfs(i);

            if (!flag) break;

        }

    }

    if (flag) printf("Yes\n");

    else printf("No\n");

    return 0;

}

/*

for(x:i) if(ans[x][j]=0) ans[i][j]=1

for(x:i) if(ans[x][j]=1)

*/


// Faster C++ solution for the same problem (measured speedup: 1.12904510983662x):
#include <iostream>

#include <cstdio>

#include <cstdlib>

#include <cmath>

#include <climits>

#include <cstring>

#include <string>

#include <vector>

#include <list>

#include <queue>

#include <stack>

#include <map>

#include <set>

#include <bitset>

#include <algorithm>

#include <functional>

#include <iomanip>

using namespace std;



#define LL long long

const int maxn = 100000 + 100;

struct Node {

    int pos;

    int dis;

    Node() {}

    Node(int p, int d) {

        pos = p;

        dis = d;

    }

};

int n, m, u, v, d;

bool flag;

int num[maxn], fa[maxn];

bool vis[maxn];

vector<Node> G[maxn];

queue<Node> que;



void Init() {

    flag = true;

    memset(vis, 0, sizeof(bool) * (n + 1));

    for(int i = 1; i <= n; ++i) {

        G[i].clear();

    }

    for(int i = 1; i <= n; ++i) {

        fa[i] = i;

    }

}



int Find(int x) {

    return (x == fa[x]? x: fa[x] = Find(fa[x]));

}



void unit(int x, int y) {

    int xx = Find(x);

    int yy = Find(y);

    fa[xx] = yy;

}



bool bfs(int x) {

    num[x] = 0;

    vis[x] = true;

    while(!que.empty()) {

        que.pop();

    }

    que.push(Node(x, 0));

    while(!que.empty()) {

        Node tmp = que.front();

        que.pop();

        int len = G[tmp.pos].size();

        for(int i = 0; i < len; ++i) {

            int pos = G[tmp.pos][i].pos;

            int d = G[tmp.pos][i].dis;

            if(!vis[pos]) {

                vis[pos] = true;

                num[pos] = tmp.dis + d;

                que.push(Node(pos, num[pos]));

            } else if(num[pos] != tmp.dis + d) {

                return false;

            }

        }

    }

    return true;

}



int main() {

    #ifdef LOCAL

        freopen("test.txt", "r", stdin);

//    freopen("out.txt", "w", stdout);

    #endif // LOCAL

    ios::sync_with_stdio(false);



    while(scanf("%d%d", &n, &m) != EOF) {

        Init();

        for(int i = 0; i < m; ++i) {

            scanf("%d%d%d", &u, &v, &d);

            G[u].push_back(Node(v, d));

            G[v].push_back(Node(u, -d));

            unit(v, u);

        }

        for(int i = 1; i <= n; ++i) {

            if(!vis[Find(i)]) {

                if(!bfs(Find(i))) {

                    flag = false;

                    break;

                }

            }

        }

        if(flag) {

            printf("Yes\n");

        } else {

            printf("No\n");

        }

    }



    return 0;

}