#include <bits/stdc++.h>
using namespace std;
int getDistance(int from, int to, vector<vector<int>>& distance,
                vector<int>& path, int N);
int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> distance(N + 1, vector<int>(N + 1, INT_MAX));
  vector<int> path;
  for (int i = 0; i < M; i++) {
    int L, R, D;
    cin >> L >> R >> D;
    int dist = getDistance(L, R, distance, path, N);
    if (dist == INT_MAX) {
      distance[L][R] = D;
      distance[R][L] = -D;
    } else {
      if (dist != D) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}
int getDistance(int from, int to, vector<vector<int>>& distance,
                vector<int>& path, int N) {
  if (distance[from][to] != INT_MAX) {
    return distance[from][to];
  } else {
    for (int i = 1; i <= N; i++) {
      if (i == from) continue;
      if (distance[from][i] != INT_MAX) {
        int d = getDistance(i, to, distance, path, N);
        if (d != INT_MAX) {
          return d + distance[from][i];
        }
      }
    }
    return INT_MAX;
  }
}
