#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
ll MOD = 1e9 + 7;
ll INF = 1e18;
struct Edge {
  int src, dst;
  int weight;
  Edge(int src, int dst, int weight) : src(src), dst(dst), weight(weight) {}
};
vector<vector<Edge> > g;
vector<ll> vec;
vector<vector<ll> > have;
bool h = true;
void dfs(int x, int reg, int prev) {
  if (vec[x] == 1e18) {
    vec[x] = reg;
  } else {
    if (reg != vec[x]) {
      h = false;
      return;
    }
  }
  for (int i = 0; i < (int)(g[x].size()); i++) {
    if (have[i][g[x][i].dst] == 0 && prev != g[x][i].dst) {
      have[i][g[x][i].dst] = 1;
      dfs(g[x][i].dst, vec[x] + g[x][i].weight, x);
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, m;
  cin >> n >> m;
  vec.resize(n + 1, 1e18);
  have.resize(n + 1, vector<ll>(n + 1));
  g.resize(n + 1);
  for (int i = 0; i < (int)(m); i++) {
    ll l, r, d;
    cin >> l >> r >> d;
    g[l].push_back(Edge(l, r, d));
    g[r].push_back(Edge(r, l, -d));
  }
  for (ll(i) = (1); (i) < (n + 1); ++(i)) {
    if (vec[i] == 1e18) {
      dfs(i, 0, -1);
    }
  }
  for (ll(i) = (1); (i) < (n + 1); ++(i)) {
  }
  if (h) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
