#include <bits/stdc++.h>
using namespace std;
struct Edge {
  long long from;
  long long to;
  long long cost;
  Edge(int from, int to, long long cost) {
    this->from = from;
    this->to = to;
    this->cost = cost;
  }
};
struct Graph {
  vector<vector<int>> graph;
  vector<Edge> edges;
  int n;
  Graph(int n) {
    graph.resize(n);
    this->n = n;
  }
  void append(Edge &e) {
    edges.push_back(e);
    graph[e.from].push_back(edges.size() - 1);
  }
};
struct Range {
  long long r;
  long long l;
  long long d;
};
const long long NOT_VISITED = -100000000000000ll;
bool fin = false;
array<long long, 100000> xs;
array<bool, 1000000> visited;
void dfs(Graph &g, int start) {
  if (fin) return;
  visited[start] = true;
  for (int ei : g.graph[start]) {
    if (fin) return;
    auto &e = g.edges[ei];
    if (xs[e.to] == NOT_VISITED) {
      xs[e.to] = xs[e.from] + e.cost;
      dfs(g, e.to);
    } else if (xs[e.to] != xs[e.from] + e.cost) {
      fin = true;
      return;
    }
  }
  visited[start] = false;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<Range> vs(n);
  Graph g(n);
  for (int i = 0; i < m; i++) {
    Range r;
    cin >> r.l >> r.r >> r.d;
    r.l--;
    r.r--;
    Edge e1(r.l, r.r, r.d);
    g.append(e1);
    Edge e2(r.r, r.l, -r.d);
    g.append(e2);
  }
  fill(xs.begin(), xs.end(), NOT_VISITED);
  for (int i = 0; i < n; i++) {
    if (NOT_VISITED == xs[i]) {
      dfs(g, i);
    }
  }
  cout << (fin ? "No" : "Yes") << endl;
}
