#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int node;
  long long dist;
  bool vis;
};
struct Node {
  long long value;
  vector<Edge> edges;
  bool vis;
};
vector<Node> nodes;
bool check(int n, long long value) {
  if (!nodes[n].vis) {
    nodes[n].value = value;
  } else if (nodes[n].value != value) {
    return false;
  }
  nodes[n].vis = true;
  for (Edge &edge : nodes[n].edges) {
    if (!edge.vis) {
      edge.vis = true;
      if (!check(edge.node, value + edge.dist)) {
        return false;
      }
    }
  }
  return true;
}
int main(int argc, char *argv[]) {
  int n, m;
  cin >> n >> m;
  nodes.resize(n);
  for (int i = 0; i < m; ++i) {
    int l, r;
    long long d;
    cin >> l >> r >> d;
    --l, --r;
    nodes[l].edges.push_back({r, d, false});
    nodes[r].edges.push_back({l, -d, false});
  }
  bool ans = true;
  for (int i = 0; i < n; ++i) {
    if (!nodes[i].vis && !nodes[i].edges.empty()) {
      if (!check(i, 0)) {
        ans = false;
      }
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}
