#include <bits/stdc++.h>
using namespace std;
static const int N_MAX = 100000;
int n;
int m;
vector<pair<int, int>> graph[N_MAX];
int x[N_MAX];
int visited[N_MAX];
bool traverse(int i) {
  if (visited[i]) return true;
  queue<int> q;
  visited[i] = 1;
  x[i] = 0;
  q.push(i);
  while (!q.empty()) {
    int v = q.back();
    q.pop();
    for (const auto& e : graph[v]) {
      if (!visited[e.first]) {
        x[e.first] = x[v] + e.second;
        visited[e.first] = 1;
        q.push(e.first);
      }
    }
  }
  return true;
}
int main(int argc, char* argv[]) {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; ++i) {
    int l, r, d;
    scanf("%d %d %d", &l, &r, &d);
    l--;
    r--;
    graph[l].push_back({r, d});
    graph[r].push_back({l, -d});
  }
  for (int i = 0; i < n; i++) {
    x[i] = 0;
    visited[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    traverse(i);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < graph[i].size(); ++j) {
      if (x[graph[i][j].first] - x[i] != graph[i][j].second) {
        puts("No");
        return 0;
      }
    }
  }
  puts("Yes");
}
