#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int from;
  int to;
  int d;
  Edge(int from, int to, int d) : from(from), to(to), d(d) {}
};
class People {
  vector<vector<Edge>> graph;
  vector<int> visited;
  vector<int> total;
  int n;

 public:
  People() {
    int m;
    cin >> n >> m;
    graph.resize(n);
    visited.resize(n, 0);
    total.resize(n);
    int l, r, d;
    for (int i = 0; i < m; ++i) {
      cin >> l >> r >> d;
      graph[l].emplace_back(l - 1, r - 1, d);
    }
  }
  bool visit(int v, int t) {
    if (1 == visited[v]) {
      return t == total[v];
    } else if (0 == visited[v]) {
      total[t] = t;
      visited[v] = 1;
      for (Edge &e : graph[v]) {
        if (!visit(e.to, t + e.d)) {
          return false;
        }
      }
      visited[v] = 2;
      return true;
    }
    return true;
  }
  bool solve() {
    for (int i = 0; i < n; ++i) {
      if (!visit(i, 0)) return false;
    }
    return true;
  }
};
int main() {
  People p;
  cout << (p.solve() ? "Yes" : "No") << endl;
  return 0;
}
