#include <bits/stdc++.h>
using namespace std;
struct graph_t {
  int n;
  int m;
  vector<pair<int, int> > edges;
  vector<long long int> cost;
  vector<long long int> cap;
};
class Solve {
 private:
  struct node {
    int id;
    bool done;
    vector<int> to;
    vector<long long int> cost;
    vector<int> from;
    vector<long long int> from_cost;
  };
  vector<node> nodes;
  int n;

 public:
  bool result;
  Solve(graph_t G) {
    n = G.n;
    nodes.resize(n);
    for (int i = 0; i < (int)n; i++) nodes[i] = {i, false, {}, {}, {}};
    for (int i = 0; i < (int)G.edges.size(); i++) {
      nodes[G.edges[i].first].to.push_back(G.edges[i].second);
      nodes[G.edges[i].first].cost.push_back(G.cost[i]);
      nodes[G.edges[i].second].from.push_back(G.edges[i].first);
      nodes[G.edges[i].second].from_cost.push_back(G.cost[i]);
    }
    vector<long long int> x(n);
    for (int i = 0; i < (int)n; i++) {
      if (nodes[i].done) continue;
      stack<int> stk;
      stk.push(i);
      x[i] = 0;
      while (stk.size()) {
        int focus = stk.top();
        stk.pop();
        if (nodes[focus].done) continue;
        nodes[focus].done = true;
        for (int j = 0; j < (int)nodes[focus].to.size(); j++) {
          stk.push(nodes[focus].to[j]);
          x[nodes[focus].to[j]] = x[focus] + nodes[focus].cost[j];
        }
      }
      stk.push(i);
      while (stk.size()) {
        int focus = stk.top();
        stk.pop();
        if (nodes[focus].done) continue;
        nodes[focus].done = true;
        for (int j = 0; j < (int)nodes[focus].from.size(); j++) {
          stk.push(nodes[focus].from[j]);
          x[nodes[focus].from[j]] = x[focus] - nodes[focus].from_cost[j];
        }
      }
    }
    result = true;
    for (int i = 0; i < (int)G.m; i++) {
      if (x[G.edges[i].second] - x[G.edges[i].first] != G.cost[i]) {
        result = false;
        break;
      }
    }
    return;
  }
};
int main() {
  graph_t G;
  cin >> G.n >> G.m;
  for (int i = 0; i < (int)G.m; i++) {
    int s, t, c;
    cin >> s >> t >> c;
    s--;
    t--;
    G.edges.push_back({s, t});
    G.cost.push_back(c);
  }
  Solve solve(G);
  if (solve.result)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
