#include <bits/stdc++.h>
using namespace std;

#define MAX_N 100001

vector<pair<int, int64_t> > adj[MAX_N];
int64_t dis[MAX_N];

void dfs(int v, int64_t d)
{
    if (dis[v]) {
        if (dis[v] != d) {
            printf("No\n");
            exit(0);
        }
        return;
    }
    dis[v] = d;
    for (int i = 0; i < adj[v].size(); i++) {
        int u = adj[v][i].first;
        int64_t w = adj[v][i].second;
        dfs(u, d + w);
    }
}

int main(void)
{
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++) {
        int l, r, d;
        scanf("%d%d%d", &l, &r, &d);
        adj[l].push_back(make_pair(r, d));
        adj[r].push_back(make_pair(l, -d));
    }
    for (int i = 1; i <= n; i++)
        if (!dis[i]) dfs(i, 0xffff);
    printf("Yes\n");
    return 0;
}
