#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
const int INF = 0x3f3f3f;
int par[N];
int v[N];
int Find(int x) {
  int temp = par[x];
  if (par[x] != x) par[x] = Find(par[x]), v[x] += v[temp];
  return par[x];
}
int main(void) {
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) par[i] = i;
  bool flag = true;
  for (int i = 1; i <= m; i++) {
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    int rootl = Find(l);
    int rootr = Find(r);
    if (rootr == rootl) {
      if (v[r] - v[l] != -d) {
        flag = false;
      } else {
        par[rootl] = rootr;
        v[rootl] = d + v[r] - v[l];
      }
    }
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
