#include <bits/stdc++.h>
using namespace std;
const double pi =
    3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod = 1000000007;
vector<int> i2g;
vector<vector<int>> g2i;
void union_init(int n) {
  i2g.resize(n);
  g2i.resize(n);
  for (int i = 0; i < n; ++i) {
    i2g[i] = i;
    g2i[i].assign(1, i);
  }
}
int find(int i) { return i2g[i]; }
void merge(int ia, int ib) {
  if (i2g[ia] == i2g[ib]) return;
  if (g2i[i2g[ia]].size() < g2i[i2g[ib]].size()) {
    swap(ia, ib);
  }
  int ga = i2g[ia], gb = i2g[ib];
  for (int j : g2i[gb]) i2g[j] = ga;
  g2i[ga].insert(g2i[ga].end(), g2i[gb].begin(), g2i[gb].end());
  g2i[gb].clear();
}
bool is_same_group(int ia, int ib) { return i2g[ia] == i2g[ib]; }
struct edge {
  edge(int t, int c) {
    to = t;
    cost = c;
  }
  edge() {}
  int to, cost;
};
int main() {
  int n, m, l, r, d;
  vector<vector<edge>> g;
  g.reserve(101010);
  int b[101010] = {};
  cin >> n >> m;
  union_init(n + 1);
  for (int i = (0); i <= (n); ++i) {
    b[i] = -1;
  }
  for (int i = (0); i < (m); ++i) {
    cin >> l >> r >> d;
    edge ee;
    ee.to = r;
    ee.cost = d;
    g[l].emplace_back(r, d);
    ee.to = l;
    ee.cost = -d;
    g[r].push_back(ee);
    merge(l, r);
  }
  for (int i = (1); i <= (n); ++i) {
    if (b[i] == -1)
      b[i] = mod;
    else
      continue;
    for (auto itr = g[i].begin() - g[i].begin();
         itr != g[i].end() - g[i].begin(); ++itr) {
      if (b[g[i][itr].to] != -1 && b[g[i][itr].to] != b[i] + g[i][itr].cost) {
        cout << "No" << endl;
        return 0;
      }
      b[g[i][itr].to] = b[i] + g[i][itr].cost;
    }
    for (int j : g2i[i2g[i]])
      for (auto itr = g[j].begin() - g[j].begin();
           itr != g[j].end() - g[j].begin(); ++itr) {
        if (b[g[j][itr].to] != -1 && b[g[j][itr].to] != b[j] + g[j][itr].cost) {
          cout << "No" << endl;
          return 0;
        }
        b[g[j][itr].to] = b[j] + g[j][itr].cost;
      }
  }
  cout << "Yes" << endl;
  return 0;
}
