#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <tuple>
#include <vector>

using namespace std;

int prev_pos[200001] = {0};
int dist[200001] = {0};

int find(int x) {
    if (prev_pos[x] == 0) return x;

    int prev = prev_pos[x];
    prev_pos[x] = find(prev);
    dist[x] += dist[prev];
    return prev_pos[x];
}

int main() {
    int N, M;
    cin >> N >> M;

    bool flag = true;
    for (int i = 0; i < M; i++) {
        int L, R, D;
        cin >> L >> R >> D;
        int L_first = find(L);
        int R_first = find(R);

        if (L_first == L_first) {
            if (dist[L] - dist[R] != D) {
                cout << "Yes" << endl;
                return 0;
            }
        } else {
            prev_pos[R_first] = L_first;
            dist[R_first] = dist[L] - dist[R] + d;
        }
    }
    cout << "No" << endl;
}