#include <bits/stdc++.h>
using namespace std;
struct edge_t {
  int src, dest, cost;
  edge_t(int s, int d, int c) : src(s), dest(d), cost(c) {}
};
bool dfs(int n, int cur, vector<int> &pos, vector<vector<edge_t> > &edges) {
  int m = edges[cur].size();
  for (int j = 0; j < m; j++) {
    edge_t &e(edges[cur][j]);
    if (pos[e.dest] == INT_MAX) {
      pos[e.dest] = pos[cur] + e.cost;
      bool c = dfs(n, e.dest, pos, edges);
      if (!c) return false;
    } else {
      if (pos[e.dest] - pos[cur] != e.cost) {
        cerr << cur << " " << e.dest << " " << e.cost << endl;
        cerr << pos[cur] << " " << pos[e.dest] << endl;
        return false;
      }
    }
  }
  return true;
}
int main() {
  int n, m, l, r, d;
  cin >> n >> m;
  vector<vector<edge_t> > edges(n);
  vector<int> pos(n, INT_MAX);
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> d;
    l--;
    r--;
    edges[l].push_back(edge_t(l, r, d));
    edges[r].push_back(edge_t(r, l, -d));
  }
  string result = "Yes";
  for (int i = 0; i < n; i++)
    if (pos[i] == INT_MAX) {
      pos[i] = 0;
      int ans = dfs(n, i, pos, edges);
      if (!ans) {
        result = "No";
        break;
      }
    }
  cout << result << endl;
  return 0;
}
