#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define N 100005

vector <tuple<int, int, int>> graph[N];

int position[N];
bool positioned[N];
int visited[N];

void dfs (int v){
    if (visited[v]) return;
    visited[v] = true;
    if (!positioned[v]){
        position[v] = 0;
        positioned[v] = true;
    }
    for (auto x: graph[v]){
        int u, d, p;
        tie(u, d, p) = x;
        int l = v, r = u;
        if (p == 1)
            swap(l, r);
       ,// cout << position[l] << " " << l << " " << position[r] << " " << r << " " << d << endl;
        if (!positioned[r]){
            positioned[r] = true;
            position[r] = position[l] + d;
        }
        if (!positioned[l]){
            positioned[l] = true;
            position[l] = position[r] - d;
        }
        if (position[r] - position[l] != d){
            printf ("No\n");
            exit(0);
        }
        dfs(u);

    }
}

int main(){
    int n, m;
    scanf ("%d %d", &n, &m);

    for (int i = 0; i < m; i++){
        int a, b, d;
        scanf ("%d %d %d", &a, &b, &d);
        graph[a].emplace_back (b, d, 0);
        graph[b].emplace_back (a, d, 1);
    }

    for (int i = 1; i <= n; i++){
        dfs(i);
    }
    printf ("Yes\n");
    return 0;
}
